本文介绍了无法在 python 中导入 tensorflow,windows 10 64 位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 python 制作一个 AI 聊天机器人.这需要张量流.我使用 pip 安装它,当我尝试导入它时,它不起作用.我得到了这个回溯:
I am trying to make a AI chatbot using python. This requires tensorflow. I installed it using pip and when I try to import it, it isn't working. I got this Traceback:
安装
C:\Users\vross>pip3 install tensorflow
Requirement already satisfied: tensorflow in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (2.1.0)
Requirement already satisfied: astor>=0.6.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.8.1)
Requirement already satisfied: wrapt>=1.11.1 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.12.0)
Requirement already satisfied: gast==0.2.2 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.2.2)
Requirement already satisfied: grpcio>=1.8.6 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.27.2)
Requirement already satisfied: wheel>=0.26; python_version >= "3" in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.34.2)
Requirement already satisfied: scipy==1.4.1; python_version >= "3" in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.4.1)
Requirement already satisfied: google-pasta>=0.1.6 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.1.8)
Requirement already satisfied: keras-preprocessing>=1.1.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.1.0)
Requirement already satisfied: opt-einsum>=2.3.2 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (3.1.0)
Requirement already satisfied: tensorflow-estimator<2.2.0,>=2.1.0rc0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (2.1.0)
Requirement already satisfied: six>=1.12.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.14.0)
Requirement already satisfied: keras-applications>=1.0.8 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.0.8)
Requirement already satisfied: numpy<2.0,>=1.16.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.18.1)
Requirement already satisfied: tensorboard<2.2.0,>=2.1.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (2.1.0)
Requirement already satisfied: termcolor>=1.1.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.1.0)
Requirement already satisfied: protobuf>=3.8.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (3.11.3)
Requirement already satisfied: absl-py>=0.7.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.9.0)
Requirement already satisfied: h5py in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from keras-applications>=1.0.8->tensorflow) (2.10.0)
Requirement already satisfied: requests<3,>=2.21.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (2.23.0)
Requirement already satisfied: werkzeug>=0.11.15 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (1.0.0)
Requirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (0.4.1)
Requirement already satisfied: markdown>=2.6.8 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (3.2.1)
Requirement already satisfied: setuptools>=41.0.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (45.2.0)
Requirement already satisfied: google-auth<2,>=1.6.3 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<2.2.0,>=2.1.0->tensorflow) (1.11.2)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (2.9)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (2019.11.28)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from requests<3,>=2.21.0->tensorboard<2.2.0,>=2.1.0->tensorflow) (1.25.8)
Requirement already satisfied: requests-oauthlib>=0.7.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.2.0,>=2.1.0->tensorflow) (1.3.0)
Requirement already satisfied: rsa<4.1,>=3.1.4 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow) (4.0)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow) (4.0.0)
Requirement already satisfied: pyasn1-modules>=0.2.1 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow) (0.2.8)
Requirement already satisfied: oauthlib>=3.0.0 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.2.0,>=2.1.0->tensorflow) (3.1.0)
Requirement already satisfied: pyasn1>=0.1.3 in c:\users\vross\appdata\local\programs\python\python36\lib\site-packages (from rsa<4.1,>=3.1.4->google-auth<2,>=1.6.3->tensorboard<2.2.0,>=2.1.0->tensorflow) (0.4.8)
互动环节
C:\Users\vross>python
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 13:35:33) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\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\vross\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Kan opgegeven module niet vinden.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
from tensorflow_core import *
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\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\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\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\vross\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\vross\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Kan opgegeven module niet vinden.
推荐答案
请按照 TensorFlow 网站的说明进行操作.如果您使用较低版本,我建议安装 Tensorflow 2.
Please follow the instructions from TensorFlow website. I recommend install Tensorflow 2, if you are using lower versions.
您需要从 此处.
如果您遇到任何其他问题,可能的原因是
If you are facing any other issues possible reasons are
- 您的 CPU 不支持 AVX2 指令
- 你的 CPU/Python 是 32 位的
- 有一个库位于其他位置/未安装在您的系统上,无法加载.
Please refer tested build configurations for windows CPU and GPU.
这篇关于无法在 python 中导入 tensorflow,windows 10 64 位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!