tensorflow - 无法导入 TensorFlow 2.3
问题描述
我正在使用 Windows 10 并使用以下方法通过 Anaconda 安装了 Tensorflow:
pip install tensorflow
使用此代码检查 tensorflow 是否安装正确:
# tensorflow
import tensorflow
print('tensorflow: %s' % tensorflow.__version__)
导入 tensorflow 时出现以下错误:
Traceback (most recent call last):
File "C:\Users\Muril\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: Não foi possível encontrar o módulo especificado.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "deep_versions.py", line 2, in <module>
import tensorflow
File "C:\Users\Muril\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Muril\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\Muril\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\Muril\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Muril\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Muril\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: Não foi possível encontrar o módulo especificado.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
有关如何解决此问题的任何想法?这里有一些额外的信息:
(base) C:\Users\Muril>python -V
Python 3.8.3
(base) C:\Users\Muril>pip show tensorflow
Name: tensorflow
Version: 2.3.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
解决方案
TF 2.6 版本的编辑代码。
import tensorflow as tf
print(tf.__version__)
print('tensorflow: %s' % tf.__version__)
推荐阅读
- java - 在运行时设置 Spring Boot Jar DB URL
- corda - 任何可用于规划和设计 CORDA 网络/节点的 IAM(用户身份验证和权限)的指南?
- r - R 检查没有看到我的包裹 - 没有名为“”的包裹
- sql - 为具有共同值的所有行获取相同的 ID
- windows - if/elseif 语句在 PS 中没有按预期工作
- javascript - 如何将 Html 表格导出为 pdf 中包含多页的 Pdf?
- swift - RxSwift 订阅序列
- sql - EF - 将 EDMX 文件部署到具有不同外键名称的服务器
- css - 按钮进入项目符号列表
- javascript - 我的代码的主题转换器似乎不起作用