Tensorflow安装及问题--------那些踩不完的坑

友情提示:橙色字体的两个标题均为坑(可直接跳过看第五步)
重要的事情说三遍,换清华源!换清华源!换清华源!
不然坑到你怀疑人生

一·安装Tensorflow
1.要安装Tensorflow,因为Python3.7支持的Tensorflow版本低,所以要把它降到3.6
2.先安装Anaconda
Anaconda官网

3.配置环境变量
4.在conda里面
conda install Python=3.6

5.一篇还不错的安装博客

https://blog.csdn.net/weixin_42555080/article/details/100704078

二·呀!出现问题啦

 import tensorflow
 Traceback (most recent call last):
 File "", line 1, in <module>
 ModuleNotFoundError: No module named 'tensorflow'

pip默认安装的是最新版,但由于一些包的内核是QT的,因此会产生版本冲突的错误
解决1.pip install --upgrade --ignore-installed tensorflow-gpu

Tensorflow安装及问题--------那些踩不完的坑_第1张图片

a>解决第一个Error:说的是spyder 3.3.6 组件需要一个版本在5.13以下的pyqt5,所以我们先解决这个问题。这时我们要使用命令:(5.13不行!5.13不行!5.13不行!)

pip install --user pyqt5==5.12.0

新的Error:会提示找不到合适的SIP版本
b>解决第二个Error:说的是spyder 3.3.6 组件需要一个版本在5.13以下的pyqtwebengine,所以我们先解决这个问题

pip install --user pyqtwebengine==5.12.0

c>解决第三个Error:

pip install --user pytest-cov==2.8.1 -i 

ERROR: pytest-astropy 0.8.0 requires pytest-filter-subpackage>=0.1, which is not installed.

一个错误,即第四个错误
d>解决第四个Error:

pip install --user pytest-filter-subpackage==0.1.1

##Error会越解决越深,要随时记录进度;及时跳出Error循环
(2)回到第一层Error:

pip install --upgrade --ignore-installed tensorflow-gpu

a> 新的Error:
ERROR: astroid 2.3.3 has requirement wrapt==1.11.*, but you’ll have wrapt 1.12.1 which is incompatible.
发现是第一步Error的第五个Error,刚刚忘记解决了

pip install --user typed-ast==1.4.0

b> 新的Error,即第六个Error:
ERROR: astroid 2.3.3 has requirement wrapt==1.11.*, but you’ll have wrapt 1.12.1 which is incompatible.

pip install --user wrapt==1.11.2 

(3)第一层Error Over,再次安装
在安装路径下打开cmd

pip install --default-timeout=1000 --ignore-installed --upgrade tensorflow-2.1.0-cp37-cp37m-win_amd64.whl

a>第二层新的Error:
ERROR: tensorflow-2.1.0-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.

b>新的命令
pip install --upgrade tensorflow-2.1.0-cp27-none-linux_x86_64.whl

新的Error:
ERROR: tensorflow-2.1.0-cp27-none-linux_x86_64.whl is not a supported wheel on this platform.

c>之前使用的版本是3.7,后来在Anaconda里面降到了Python3.6,再换个命令
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ https://mirrors.tuna.tsinghua.edu.cn/tensorflow/windows/cpu/tensorflow-1.3.0rc0-cp36-cp36m-win_amd64.whl

d>此命令报404错误,该源不能用,以及可能服务器已撤销这个
e>目录d,c,d方法均不可用,回到第二层第一个Error
A>安装时tensorflow-2.1.0-cp37-cp37m-win_amd64.whl丢了
下载网址:https://pypi.org/project/tensorflow/#files
B>再安装
TimeoutError(“HTTPSConnectionPool(host=‘pypi.org’, port=443): Read timed out. (read timeout=15)”,)’: /simple/protobuf/

(4)第二层Error Over在Spyder里面输入测试代码

import tensorflow as tf
hello =tf.constant("hello tensorflow")
sess=tf.Session()
print(sess.run(hello)
ERROR:

ImportError: DLL load failed: 找不到指定的模块。
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.

(5)发现(3)(4)都是坑(哭了)
(tensorflow) C:\Users\Administrator>的命令窗口执行清华镜像源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/

再执行安装 :conda install tensorflow
在Spyder里面测试 OK!!
Tensorflow安装及问题--------那些踩不完的坑_第2张图片

##一篇不错关于tensorflow安装及错误出现解决博客:https://www.pythonheidong.com/blog/article/281828/

你可能感兴趣的:(tensorflow)