Python 安装tensorflow,解决报错 Could not find a version that satisfies the requirement tensorflow

时间:2024-03-23 19:29:59

如果你用的是python3,那这篇文章可能对你没什么帮助,但是如果是生产环境部署的tensorflow出现了如下这个问题:

Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
Python 安装tensorflow,解决报错 Could not find a version that satisfies the requirement tensorflow

那可能你遇到的问题跟我遇到的问题是一样的。

搞了一天才弄明白问题出现在哪里
现在把解决方法分享给大家~

一、安装python

1、下载python,这里的版本可以自己选择,以2.7.16为例子
wget https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tgz

2、解压、编译安装(依次执行以下5条命令)#
tar -zxvf Python-2.7.16.tgz

cd Python-2.7.16

./configure --prefix=/usr/local/python-2.7.16 --enable-unicode=ucs4
注:这里加编码格式很重要,加编码格式就是为了解决上面遇到的问题的。

make

make install

3、建立映射

ln -s /usr/local/python-2.7.16/bin/python /usr/bin/python2.7.16

看看python2.7.16
Python 安装tensorflow,解决报错 Could not find a version that satisfies the requirement tensorflow
到这里python2.7.16就已经安装完成了。

二、安装pip

1、先安装setup-tools

wget https://pypi.python.org/packages/45/29/8814bf414e7cd1031e1a3c8a4169218376e284ea2553cc0822a6ea1c2d78/setuptools-36.6.0.zip#md5=74663b15117d9a2cc5295d76011e6fd1

unzip setuptools-36.6.0.zip
cd setuptools-36.6.0

python2.7.16 setup.py install

2、安装pip

wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar -zxvf pip-9.0.1.tar.gz
cd pip-9.0.1
python2.7.16 setup.py install

3、建立映射
ln -s /usr/local/python-2.7.16/bin/pip /usr/bin/pip

看看pip
Python 安装tensorflow,解决报错 Could not find a version that satisfies the requirement tensorflow
说明 pip已经安装完成了。

接下来看看能不能直接用pip安装tensorflow
Python 安装tensorflow,解决报错 Could not find a version that satisfies the requirement tensorflow
pip可以直接安装tensorflow了,这里安装的是最新版本,也可以指定版本去安装

Python 安装tensorflow,解决报错 Could not find a version that satisfies the requirement tensorflow
忽略警告,tensorflow已经可以在python2的环境下运行了。
到处就大功告成!!

鬼知道我经历了什么。。

我是一只前进的蚂蚁,希望能一起前行。

如果对您有一点帮助,一个赞就够了,感谢!

注:如果本篇博客有任何错误和建议,欢迎各位指出,不胜感激!!!