无法在Python中导入tensorflow

时间:2019-07-11 15:14:29

标签: python tensorflow

编辑:在某些Windows版本中,这似乎是一个问题。我在Linux OS上尝试了同样的方法,终于奏效了。

在我的虚拟环境中,我安装了tensorflow。然后尝试将其导入python,但导入错误。

我已经尝试了Internet上所有可用的黑客手段,但似乎没有一个对我有用。请帮忙。

  • 尝试下载必要的DLL(在system32文件夹中)
  • 尝试更改环境路径变量
  • 尝试以各种方式卸载和重新安装Python和tensorflow
  • 尝试了升级设置工具

基本导入命令

E:\tensor1>myenv\Scripts\activate.bat

(myenv) E:\tensor1>python

>>> import tensorflow

无论我尝试什么,都会无情地显示此错误:

Traceback (most recent call last):
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow.p
y", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow_i
nternal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow_i
nternal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\samiam\AppData\Local\Programs\Python\Python37\lib\imp.py", line
 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\samiam\AppData\Local\Programs\Python\Python37\lib\imp.py", line
 342, in load_dynamic
    return _load(spec)
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 "<stdin>", line 1, in <module>
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\__init__.py", line 28, in
<module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\__init__.py", line
49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow.p
y", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow.p
y", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow_i
nternal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "E:\tensor1\myenv\lib\site-packages\tensorflow\python\pywrap_tensorflow_i
nternal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\samiam\AppData\Local\Programs\Python\Python37\lib\imp.py", line
 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\samiam\AppData\Local\Programs\Python\Python37\lib\imp.py", line
 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.


Failed to load the native TensorFlow runtime.

0 个答案:

没有答案