Tensorflow ImportError:DLL加载失败:找不到指定的模块

时间:2019-10-01 11:56:09

标签: python tensorflow python-3.6

我已经看到很多问题已经问了这个,但这似乎很具体,因为似乎没有一个答案可以解决

让我解释一下我安装所有组件的步骤:

我从安装Python 3.7.4开始,然后安装了tensorflow。我运行的命令是:pip install -q tensorflow=2.0.0-alpha0。这似乎没有用,我很快就发现这是由于Python版本所致。 Tensorflow目前尚不支持3.7,因此我安装了Python 3.6.0。

然后我使用以下命令再次安装tensorflow:pip3.6 install tensorflow。请注意显式pip3.6。然后,在Visual Code的Python调试器的配置中选择python 3.6。我运行了以下代码(单行),并给了我以下错误:

Python

import tensorflow as tf

输出

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
    from tensorflow_core import *
  File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
  File "C:\Program Files\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified module could not be found.

经过一些搜索后,someone said可能由于不支持的gpu而卸载tensorflow-estimator和tensorflow-gpu可能起作用。即使我因为拥有RTX 2080而对此表示怀疑,但我还是决定试一试,但结果还是一样。

我希望你们中的任何一个都能帮助我。

谢谢!

更新

在安装Anaconda并使用conda与(而不是pip)一起安装我的软件包后,此问题已解决。但是,发生一个不错的问题。使用某行代码,我得到以下错误(与上一个错误几乎相同,但包装模块不同):

Traceback (most recent call last):
  File "c:\Users\Meine Zeinstra\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\ptvsd_launcher.py", line 43, in <module>
    main(ptvsdArgs)
  File "c:\Users\Meine Zeinstra\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
    run()
  File "c:\Users\Meine Zeinstra\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
    runpy.run_path(target, run_name='__main__')
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\Users\Meine Zeinstra\Documents\Projects\Python_Neural_Networks\Tutorial_1\Tutorial_1.py", line 1, in <module>
    import tensorflow as tf
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\tensorflow\__init__.py", line 34, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
    import numpy as np
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

希望您能帮我解决这个新问题。

0 个答案:

没有答案