为什么导入tensorflow时会出现DLL错误



我最近买了一个新的64位windows 10,并安装了pycharm。我使用的pycharm是Python 3.8。当我通过运行命令行安装tensorflow时,它运行得很好。然而,当我在pycharm文件(即import tensorflow as tf(上导入时,它产生了这样的错误:

Traceback (most recent call last):
File "C:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflowpythonpywrap_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:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflow__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflowpython__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflowpythoneagercontext.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflowpythonpywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflowpythonpywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:Usersleodeanaconda3envsScience Fairlibsite-packagestensorflowpythonpywrap_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安装。我安装tensorflow的方式是创建并激活conda环境。有关如何通过Pycharm安装tensorflow的更多信息,这里有一个有用的Youtube视频:https://www.youtube.com/watch?v=5Ym-dOS9sA&t=327s

最新更新