2017-06-05 103 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

相關問題