2017-06-05 51 views
0

我使用以下命令安装了tensorflow。无法运行导入tensorflow作为tf

pip install tensorflow 

我运行一个简单的程序,这是

import tensorflow as tf 
node1 = tf.constant(3.0, tf.float32) 
node2 = tf.constant(4.0) # also tf.float32 implicitly 
print(node1, node2) 

我上运行的程序得到以下错误。

Traceback (most recent call last): 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper 
return importlib.import_module(mname) 
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module 
return _bootstrap._gcd_import(name[level:], package, level) 
File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked 
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked 
File "<frozen importlib._bootstrap>", line 577, in module_from_spec 
File "<frozen importlib._bootstrap_external>", line 906, in create_module 
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 
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 "C:\Program Files (x86)\Python\lib\site- 
packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module> 
from tensorflow.python.pywrap_tensorflow_internal import * 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module> 
_pywrap_tensorflow_internal = swig_import_helper() 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper 
return importlib.import_module('_pywrap_tensorflow_internal') 
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module 
return _bootstrap._gcd_import(name[level:], package, level) 
ImportError: No module named '_pywrap_tensorflow_internal' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
File "first.py", line 1, in <module> 
import tensorflow as tf 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module> 
from tensorflow.python import * 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module> 
from tensorflow.python import pywrap_tensorflow 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module> 
raise ImportError(msg) 
ImportError: Traceback (most recent call last): 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper 
return importlib.import_module(mname) 
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module 
return _bootstrap._gcd_import(name[level:], package, level) 
File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked 
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked 
File "<frozen importlib._bootstrap>", line 577, in module_from_spec 
File "<frozen importlib._bootstrap_external>", line 906, in create_module 
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 
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 "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module> 
from tensorflow.python.pywrap_tensorflow_internal import * 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module> 
_pywrap_tensorflow_internal = swig_import_helper() 
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper 
return importlib.import_module('_pywrap_tensorflow_internal') 
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module 
return _bootstrap._gcd_import(name[level:], package, level) 
ImportError: No module named '_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. 

我已经更新了PIP和我的蟒蛇3.5

+0

[Windows上的TensorFlow:ImportError:No module named'\ _pywrap \ _tensorflow \ _internal']可能重复(https://stackoverflow.com/questions/43751418/tensorflow-on-windows-importerror-no-module- named-pywrap-tensorflow-internal) – user1735003

回答

0

运行程序我不太确定是什么问题,而可能是因为无能,你对错误消息,但因为你是使用python 3.x中,你不应该安装tensorflow使用:

pip3 install tensorflow 

要看到,如果你正在使用PIP 3类型:

pip3 -V 

如果您需要更多帮助,请访问官方教程maclinux

我希望这有助于

dan4o

+0

尝试通过pip3安装tensorflow进行安装。问题尚未解决。 – AkDB

+0

也打印这些值,我认为你需要使用session.run()或类似的东西。检查tensorflow安装说明的验证安装部分(位于底部)。希望它能帮助 – dan4o

0

此错误消息通常意味着TensorFlow的依赖关系中的一个不能在系统上找到。由于您在Windows上使用的是TensorFlow的纯CPU版本,最有可能丢失的DLL是msvcp140.dll,这是运行使用Microsoft Visual C++ 2015编译的程序所必需的。该DLL通常作为Visual Studio的一部分安装在开发人员计算机上,或者一些Python发行版,如Anaconda。但是,Python for Python的Python.org发行版不包含它。

您可以通过下载并安装Microsoft Visual C++ 2015 Redistributable Update 3在您的系统上安装msvcp140.dll

对于其他人谁找到这个答案,请注意this script可以帮助诊断Windows安装问题上的常见TensorFlow。

+0

真的很感激,如果你能回应这个。 https://stackoverflow.com/questions/44498771/multilayer-encoder-output-state-to-multilayer-decoder-in-seq2seq-model-tf-1-0 谢谢 –

+0

该脚本发布了已安装的结果 – AkDB

相关问题