使用tensorflow时出现错误信息

Getting Error Message while using tensorflow

我已经用pip命令安装了tensorflow。但是每当我尝试通过导入在我的代码中使用它时,它都会给我错误。我不知道为什么会收到此错误。我也无法使用 tflearn。另外,我最近才开始在 python 编码。这是错误消息:

正确观点:https://justpaste.it/56znr

Traceback (most recent call last):
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
from tensorflow_core import *
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Aaman\anaconda3\envs\chatbot\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

以下是我检查它是否安装正确的方法:

C:\Users\Aaman>pip show tensorflow     
Name: tensorflow     
Version: 2.1.0       
Summary: TensorFlow is an open source machine learning framework for everyone.   
Home-page: https://www.tensorflow.org/     
Author: Google Inc.      
Author-email: packages@tensorflow.org        
License: Apache 2.0        
Location: c:\users\aaman\anaconda3\envs\chatbot\lib\site-packages      
Requires: protobuf, scipy, keras-applications, keras-preprocessing, absl-py, tensorboard, wrapt, opt-einsum, google-pasta, astor, numpy, tensorflow-estimator, six, wheel, grpcio, gast, termcolor
Required-by:

您需要从 here.

下载并 install/update Microsoft Visual C++ 2015-2019 Redistributable (x64)

如果您遇到任何其他问题,可能的原因是

  • 你的CPU不支持AVX2指令
  • 你的CPU/Python是32位的
  • 您的系统上安装了另一个 location/not 中的库,无法加载。

请参考 windows CPU and GPU 的测试构建配置。