我在安装Tensorflow时遇到问题
我刚刚用以下命令安装了Tensorflow
$ pip install --user --upgrade tensorflow
这是我在安装后得到的最后几行代码
Successfully built absl-py gast
Installing collected packages: wheel, six, grpcio, absl-py, numpy, gast, astor, tensorflow, h5py, werkzeug, se tuptools
Successfully installed absl-py-0.7.1 astor-0.8.0 gast-0.2.2 grpcio-1.21.1 h5py-2.9.0 numpy-1.16.4 setuptools-4 1.0.1 six-1.12.0 tensorflow-1.13.1 werkzeug-0.15.4 wheel-0.33.4 `````然后当我输入以下命令时:
$ pip install --upgrade tensorflow
我确实得到了一堆requirement already up-to-date,如下所示。
Requirement already up-to-date: tensorflow in c:\users\xxx\appdata\roaming\python\python36\site-packages
Requirement already up-to-date: tensorflow-estimator<1.14.0rc0,>=1.13.0 in c:\programdata\anaconda3\lib\site-p ackages (from tensorflow)
Requirement already up-to-date: numpy>=1.13.3 in c:\users\xxx\appdata\roaming\python\python36\site-packag es (from tensorflow)
Requirement already up-to-date: gast>=0.2.0 in c:\users\xxx\appdata\roaming\python\python36\site-packages (from tensorflow)
Requirement already up-to-date: six>=1.10.0 in c:\users\xxx\appdata\roaming\python\python36\site-packages (from tensorflow)
Requirement already up-to-date: keras-preprocessing>=1.0.5 in c:\programdata\anaconda3\lib\site-packages (from tensorflow)
Requirement already up-to-date: tensorboard<1.14.0,>=1.13.0 in c:\programdata\anaconda3\lib\site-packages (fro m tensorflow)
Requirement already up-to-date: astor>=0.6.0 in c:\users\xxxx\appdata\roaming\python\python36\site-package s (from tensorflow)
Requirement already up-to-date: termcolor>=1.1.0 in c:\programdata\anaconda3\lib\site-packages (from tensorflo w)
Requirement already up-to-date: wheel>=0.26 in c:\users\xxxx\appdata\roaming\python\python36\site-packages (from tensorflow)
Requirement already up-to-date: keras-applications>=1.0.6 in c:\programdata\anaconda3\lib\site-packages (from tensorflow)
Requirement already up-to-date: grpcio>=1.8.6 in c:\users\xxxx\appdata\roaming\python\python36\site-packag es (from tensorflow)
Requirement already up-to-date: protobuf>=3.6.1 in c:\programdata\anaconda3\lib\site-packages (from tensorflow ) 我将其解释为所有内容都已安装和升级(我说错了吗?)
现在我的问题是,当我尝试在Jupyter notebook中导入Tensorflow let时,我得到了以下错误消息
ImportError: Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\ProgramData\Anaconda3\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\ProgramData\Anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
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.你知道原因是什么吗?我需要改变什么才能让tensorflow启动并运行?
提前感谢大家对上述问题的任何帮助。
发布于 2020-04-15 02:29:41
我已经解决了这个问题,通过使用以下命令将tensorflow降级到2.0版本:
pip安装tensorflow==2.0
然后像这样使用:
从tensorflow.keras.applications导入vgg19从tensorflow.keras.models导入load_model
我希望它能帮上忙。
https://stackoverflow.com/questions/56667802
复制相似问题