I've been trying for 3 days to install tensorflow with CPU support only. I can install it using native pip, but when I'm running the import tensorflow as tf line in Python 3.6 Shell these errors appear :
我已经尝试了3天只安装具有CPU支持的tensorflow。我可以使用native pip安装它,但是当我在Python 3.6 Shell中运行导入tensorflow作为tf行时,会出现以下错误:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import tensorflow as tf
File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: 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.
I've followed instructions from the following links:
我已按照以下链接中的说明操作:
https://github.com/tensorflow/tensorflow/issues/10033
On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error
在Windows上,运行“import tensorflow”会生成名为“_pywrap_tensorflow”的无模块错误
and other similar links that suggested the same solutions.
以及提出相同解决方案的其他类似链接。
I've tried including ".DLL" files in my PATHEX variable and also searched for my "mscvp140.dll" in computer. I found some directories from Visual Studio with this file and I've added one of them in my PATH variable. Still, I get the same error when I'm running the import line.
我尝试在我的PATHEX变量中包含“.DLL”文件,并在计算机中搜索我的“mscvp140.dll”。我在Visual Studio中找到了一些带有这个文件的目录,我在其PATH变量中添加了其中一个目录。但是,当我运行导入行时,我得到了同样的错误。
Does anyone solved this problem before? Perhaps I should add a certain folder in my PATH variable or my tensorflow may try to find CUDA even it's a CPU version? I would really appreciate your help.
有没有人以前解决过这个问题?也许我应该在我的PATH变量中添加某个文件夹,否则我的张量流可能会尝试找到CUDA,即使它是CPU版本?我将衷心感谢您的帮助。
1 个解决方案
#1
0
I finally solved the problem using the following link:
我终于使用以下链接解决了这个问题:
On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error
在Windows上,运行“import tensorflow”会生成名为“_pywrap_tensorflow”的无模块错误
I have downgraded my tensorflow version from 1.7 to 1.5. Apparently, the newer version needs AVX instruction set which is not supported by my CPU. I hope this is going to be helpful for other users.
我已将tensorflow版本从1.7降级到1.5。显然,较新的版本需要我的CPU不支持的AVX指令集。我希望这会对其他用户有所帮助。
#1
0
I finally solved the problem using the following link:
我终于使用以下链接解决了这个问题:
On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error
在Windows上,运行“import tensorflow”会生成名为“_pywrap_tensorflow”的无模块错误
I have downgraded my tensorflow version from 1.7 to 1.5. Apparently, the newer version needs AVX instruction set which is not supported by my CPU. I hope this is going to be helpful for other users.
我已将tensorflow版本从1.7降级到1.5。显然,较新的版本需要我的CPU不支持的AVX指令集。我希望这会对其他用户有所帮助。