Skip to main content
 首页 » 编程设计

python之Windows CPU 版本 : ImportError: No module named '_pywrap_tensorflow_internal' 上的 TensorFlow

2025年01月19日26kuangbin

我已按照类似 question 中的所有说明进行操作,我正在使用最新版本的 tensorflow CPU 版本的 Windows 从 here但我仍然收到模块未找到错误,我运行了上一个答案中的脚本并安装了最新版本的 Microsoft C++ Runtime 我已附上错误消息任何帮助将不胜感激

堆栈跟踪

    >>> import tensorflow as tf 
Traceback (most recent call last): 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_ten 
sorflow_internal.py", line 18, in swig_import_helper 
    return importlib.import_module(mname) 
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in impor 
t_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import 
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load 
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked 
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked 
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec 
  File "<frozen importlib._bootstrap_external>", line 922, in create_module 
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed 
ImportError: DLL load failed with error code -1073741795 
 
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_ten 
sorflow.py", line 58, in <module> 
    from tensorflow.python.pywrap_tensorflow_internal import * 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_ten 
sorflow_internal.py", line 21, in <module> 
    _pywrap_tensorflow_internal = swig_import_helper() 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_ten 
sorflow_internal.py", line 20, in swig_import_helper 
    return importlib.import_module('_pywrap_tensorflow_internal') 
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in impor 
t_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 "<stdin>", line 1, in <module> 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", lin 
e 24, in <module> 
    from tensorflow.python import * 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\__init__.p 
y", line 49, in <module> 
    from tensorflow.python import pywrap_tensorflow 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_ten 
sorflow.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_ten 
sorflow_internal.py", line 18, in swig_import_helper 
    return importlib.import_module(mname) 
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in impor 
t_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import 
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load 
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked 
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked 
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec 
  File "<frozen importlib._bootstrap_external>", line 922, in create_module 
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed 
ImportError: DLL load failed with error code -1073741795 
 
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_ten 
sorflow.py", line 58, in <module> 
    from tensorflow.python.pywrap_tensorflow_internal import * 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_ten 
sorflow_internal.py", line 21, in <module> 
    _pywrap_tensorflow_internal = swig_import_helper() 
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\python\pywrap_ten 
sorflow_internal.py", line 20, in swig_import_helper 
    return importlib.import_module('_pywrap_tensorflow_internal') 
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in impor 
t_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_probl 
ems 
 
for some common reasons and solutions.  Include the entire stack trace 
above this error message when asking for help. 

请您参考如下方法:

我找到了一个简单的解决方案。虽然设置在另一台计算机上有效,但我需要在这里安装旧版本的 tensorflow。

  • 只需运行下面的命令,它将清除所有依赖项,然后更新它。这对我有用

pip install tensorflow==1.5