【问题标题】:While importing tensor flow, I am facing this issue在导入张量流时,我遇到了这个问题
【发布时间】:2022-01-15 03:30:55
【问题描述】:
importError                               Traceback (most recent call last)
~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     63   try:
---> 64     from tensorflow.python._pywrap_tensorflow_internal import *
     65   # This try catch logic is because there is no bazel equivalent for py_extension.

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:

ImportError                               Traceback (most recent call last)
<ipython-input-1-370f0fe8bb94> in <module>
----> 1 import tensorflow

~\anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
     39 import sys as _sys
     40 
---> 41 from tensorflow.python.tools import module_util as _module_util
     42 from tensorflow.python.util.lazy_loader import LazyLoader as _LazyLoader
     43 

~\anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
     38 # pylint: disable=wildcard-import,g-bad-import-order,g-import-not-at-top
     39 
---> 40 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
     41 from tensorflow.python.eager import context
     42 

~\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
     77     sys.setdlopenflags(_default_dlopen_flags)
     78 except ImportError:
---> 79   raise ImportError(
     80       f'{traceback.format_exc()}'
     81       f'\n\nFailed to load the native TensorFlow runtime.\n'

ImportError: Traceback (most recent call last):
  File "C:\Users\user\anaconda3\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.

【问题讨论】:

  • 请提供足够的代码,以便其他人更好地理解或重现问题。

标签: python python-3.x tensorflow


【解决方案1】:

您似乎正在使用anaconda 环境,而tensorflow 无法在您的系统中正确安装。

为此,请使用以下代码为tensorflow 创建一个新环境:

conda create -n tf tensorflow 
conda activate tf

conda install pip
pip install tensorflow

选择anaconda平台下的"tf"环境,在同一环境中打开JUPYTER notebook,再次输入此代码:

import tensorflow as tf
printf(tf.__version__)

如果没有错误,说明tensorflow安装成功。

请查看此link 以供参考。

【讨论】:

    猜你喜欢
    • 2018-12-22
    • 2019-10-07
    • 2021-01-08
    • 1970-01-01
    • 2016-10-20
    • 2022-07-16
    • 2016-10-18
    • 2019-01-17
    • 1970-01-01
    相关资源
    最近更新 更多