tensorFlow解决问题ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'

环境

64位机win7旗舰sp1

 

Pycharm Community Edition 2017.2

tensorFlow1.4.0

报错

ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'

详情

"C:\Program Files\Anaconda3\python.exe" C:/tensorflow-1.1.0/tensorflow/examples/tutorials/mnist/mnist_softmax.py C:\tensorflow-1.1.0\tensorflow\examples\tutorials\mnist\input_data
Traceback (most recent call last):
  File "C:\tensorflow-1.1.0\tensorflow\python\pywrap_tensorflow.py", line 41, in 
    from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/tensorflow-1.1.0/tensorflow/examples/tutorials/mnist/mnist_softmax.py", line 28, in 
    from tensorflow.examples.tutorials.mnist import input_data
  File "C:\tensorflow-1.1.0\tensorflow\__init__.py", line 24, in 
    from tensorflow.python import *
  File "C:\tensorflow-1.1.0\tensorflow\python\__init__.py", line 51, in 
    from tensorflow.python import pywrap_tensorflow
  File "C:\tensorflow-1.1.0\tensorflow\python\pywrap_tensorflow.py", line 52, in 
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\tensorflow-1.1.0\tensorflow\python\pywrap_tensorflow.py", line 41, in 
    from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.
Process finished with exit code 1

原因

 

1.pycharm导入了tensorflow-1.1.0,执行mnist_softmax.py文件时,由于
python误以为tensorflow目录中的tensorflow就是要导入的模块。
解决办法,不要在tensorflow中运行python或者ipython
可以在cmd中运行,但不要在tensorFlow同一目录下执行python命令。

 

C:\>python C:\tensorflow-1.1.0\tensorflow\examples\tutorials\mnist\mnist_softmax_xla.py
Extracting /tmp/tensorflow/mnist/input_data\train-images-idx3-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data\train-labels-idx1-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data\t10k-images-idx3-ubyte.gz
Extracting /tmp/tensorflow/mnist/input_data\t10k-labels-idx1-ubyte.gz
2017-11-12 11:19:49.709578: I C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
0.9207

 

 

 

2.编译环境问题

windows cpu版, tensorflow安装后,在Python环境下“import tensorflow”时出现上述错误。 

解决办法: install the Visual C++ Redistributable 2015 x64 as MSVCP140.DLL may be missing in your system. 

Visual C++ Redistributable 2015 x64下载地址:

链接: https://pan.baidu.com/s/1CJMrG7wZtsB5E8QvWki7Tw

官网下载:

https://www.microsoft.com/en-us/download/details.aspx?id=48145

你可能感兴趣的:(人工智能,TensorFlow)