pip安装tensorflow出现Read timed out的解决办法

pip安装tensorflow出现Read timed out的解决办法

楼主的第一篇博客,写得不好请多谅解。
在这里插入图片描述
这次是楼主尝试用pip安装tensorflow,然而由于pip默认的包下载路径为python官网,所以下载速度只有几KB,等了一会之后出现了Read timed out的错误,于是上网搜索解决办法,然后尝试了更改超时时间的方法:

输入:
pip --default-timeout=1000 install -U tensorflow

然而还是不行,网速还是太慢了,接着又出现Read timed out的错误,接着继续搜索解决办法,发现可以更换国内的pypi源

输入:
pip --default-timeout=1000 install -U tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple

这是清华大学开源软件镜像站,常用的镜像库还有阿里、豆瓣等。这次楼主的尝试很成功,网速瞬间变成MB级的,但是过了一会又出现了一点问题:
在这里插入图片描述
在这里插入图片描述
遇到了Error:

google-auth 1.14.1 has requirement setuptools>=40.3.0, but you'll have setuptools 40.2.0 which is incompatible.
tensorboard 2.1.1 has requirement setuptools>=41.0.0, but you'll have setuptools 40.2.0 which is incompatible.
Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

原因:setuptools 版本太旧 , wrapt 不能卸载
解决办法:更新setuptools版本,更新 wrapt
输入:
pip install --upgrade setuptools -i https://pypi.tuna.tsinghua.edu.cn/simple
输入:
pip install --ignore-installed wrapt -i https://pypi.tuna.tsinghua.edu.cn/simple

在这里插入图片描述
在这里插入图片描述
setuptools和 wrapt更新成功!
然后重新输入:
pip --default-timeout=1000 install -U tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
这样,就可以安装tensorflow啦!

当然还有一种办法:不更新setuptools和 wrapt,直接强制安装tensorflow,后面最好还是加上-i https://pypi.tuna.tsinghua.edu.cn/simple,这个办法楼主还没有试过,但应该靠谱。
输入:
pip install --ignore-installed tensorflow
或者输入 (推荐)
pip install --ignore-installed tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple

猜你喜欢

转载自blog.csdn.net/weixin_44842318/article/details/105904057