首页 > 解决方案 > 安装 TensorFlow 的问题

问题描述

我在安装 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 时,我收到以下错误消息

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 启动和运行吗?

提前感谢大家对上述问题的任何帮助。

标签: pythontensorflow

解决方案


我通过使用以下命令将 tensorflow 降级到 2.0 版解决了这个问题:

点安装张量流==2.0

然后像这样使用:

从 tensorflow.keras.applications 导入 vgg19 从 tensorflow.keras.models 导入 load_model

我希望它有所帮助。


推荐阅读