Python:我如何解决这个ImportError



我通过pip install安装了Tensorflow,它很成功,但当我尝试使用它时,我遇到了以下ImportError:

Traceback (most recent call last):
File "C:UsersAKINAppDataLocalProgramsPythonPython38libsite-packagestensorflowpythonpywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/AKIN/PythonProjects/sample_codes/trial_tf.py", line 2, in <module>
import tensorflow as tf
File "C:UsersAKINAppDataLocalProgramsPythonPython38libsite-packagestensorflow__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:UsersAKINAppDataLocalProgramsPythonPython38libsite-packagestensorflowpython__init__.py", line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "C:UsersAKINAppDataLocalProgramsPythonPython38libsite-packagestensorflowpythonpywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:UsersAKINAppDataLocalProgramsPythonPython38libsite-packagestensorflowpythonpywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.

我已经检查过了,我看到Windows构建失败,但我不知道这是否是影响它的原因:

https://github.com/tensorflow/tensorflow

发生了什么?

经过数百次谷歌搜索和Youtube视频,我在大约一个月前找到了这个问题的解决方案。与python中的其他第三方模块(如Pandas、Matplotlib等(不同,它们需要安装pip,有一组不同的步骤,包括安装具有Cuda功能的GPU或CPU的NVIDIA(Tensorflow可与任一GPU或CPU配合使用(,以及激活第二环境。

我发现一个特别有用的youtube视频简要解释了在没有DLL错误的情况下安装tensorflow的每个步骤。以下是链接:https://www.youtube.com/watch?v=5Ym-dOS9sA&t=327s

讲师使用Pycharm,但我相信您可以使用另一个IDE轻松完成每一步。

如果您有任何问题或想要澄清,请毫不犹豫地询问。祝你好运!:(

相关内容

  • 没有找到相关文章