我在Windows 10上安装了Anaconda3和Python 3.6.7,但是在导入Tensorflow时发生错误,所有详细说明和消息均附在下面: 我试图将我的Python 3.7更改为很多人说与Tensorflow不兼容的Python 3.7,但是我仍然无法导入Tensorflow,有人知道我该怎么做才能解决此问题? // ================================================ ======================
(tensorflow)C:\ Users \ user> python --version Python 3.6.7 :: Anaconda自定义(64位)
(tensorflow) C:\Users\user>python
Python 3.6.7 |Anaconda custom (64-bit)| (default, Oct 28 2018, 19:44:12) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\imp.py", line 297, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\user\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
答案 0 :(得分:0)
在具有相同python版本的Windows上,我遇到了类似的问题。请尝试以下步骤:
使用conda软件包管理器安装TensorFlow版本1.10.0。
conda install tensorflow=1.10.0
安装完成后,请确保在软件包列表中有3个软件包:tensorflow,tensorflow-base和tensorboard。
基于tensorflow的软件包将解决该问题。
最后安装Microsoft Visual Studio C ++ Redistributable。
答案 1 :(得分:0)
您可以尝试以下步骤:
conda create --name tensorflow python = 3.6
激活张量流
conda install -c conda-forge tensorflow = 1.0.0
尝试导入tensorflow