为什么导入tensorflow会出现DLL错误?
Why does a DLL error appear when importing tensorflow?
我最近得到了一个新的 64 位 windows 10 并安装了 pycharm。我使用的 pycharm 是 Python 3.8。
当我通过 运行 命令行安装 tensorflow 时,它工作正常。但是,当我导入 pycharm 文件(即 import tensorflow as tf
)时,它产生了这样的错误:
Traceback (most recent call last):
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/leode/PycharmProjects/Science Fair/project.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
但是当我导入时 tensorboard_plugin_wit:
import tensorboard_plugin_wit
它工作正常。
出了什么问题?如果你们中的任何人需要任何进一步的说明,请发表评论-我不是处理计算机的专家,所以我会尽力回答:)
我明白问题出在哪里了。与 python 中的许多第三方模块不同,安装 tensorflow 需要的不仅仅是 pip install 。我安装 tensorflow 的方式是创建并激活一个 conda 环境。有关如何通过 Pycharm 安装 tensorflow 的更多信息,这里有一个有用的 Youtube 视频:https://www.youtube.com/watch?v=5Ym-dOS9ssA&t=327s
我最近得到了一个新的 64 位 windows 10 并安装了 pycharm。我使用的 pycharm 是 Python 3.8。
当我通过 运行 命令行安装 tensorflow 时,它工作正常。但是,当我导入 pycharm 文件(即 import tensorflow as tf
)时,它产生了这样的错误:
Traceback (most recent call last):
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/leode/PycharmProjects/Science Fair/project.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\leode\anaconda3\envs\Science Fair\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
Failed to load the native TensorFlow runtime.
但是当我导入时 tensorboard_plugin_wit:
import tensorboard_plugin_wit
它工作正常。
出了什么问题?如果你们中的任何人需要任何进一步的说明,请发表评论-我不是处理计算机的专家,所以我会尽力回答:)
我明白问题出在哪里了。与 python 中的许多第三方模块不同,安装 tensorflow 需要的不仅仅是 pip install 。我安装 tensorflow 的方式是创建并激活一个 conda 环境。有关如何通过 Pycharm 安装 tensorflow 的更多信息,这里有一个有用的 Youtube 视频:https://www.youtube.com/watch?v=5Ym-dOS9ssA&t=327s