1)首先来安装依赖
yum -y install gcc gcc-c++
yum -y groupinstall “Development tools”
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel
2)然后下载 Python-3.7.0 的源码并解压:
mkdir -p ~/src
cd ~/src
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
tar -zxvf Python-3.7.0.tgz
3)编译安装:
cd Python-3.7.0
./configure –prefix=/usr/local/python3
make && make install
4)最后创建软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5)测试
python3 --version
pip3 --version
升级pip3命令:
pip3 install –upgrade pip
安装指令:
pip3 install pipenv
错误信息:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting virtualenv
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/virtualenv/
Could not fetch URL https://pypi.org/simple/virtualenv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/virtualenv/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement virtualenv (from versions: )
No matching distribution found for virtualenv
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
原因:
yum 安装的openssl 版本都比较低,即pip依赖出现问题,导致pip未够正常使用,需要更新依赖!
解决方案:
戳这里 谢谢作者分享!
安装指令:
pip3 install pipenv
错误信息(此时简略错误信息):
ReadTimeoutError
解决方案:
使用以下指令:
pip3 --default-timeout=100 install pipenv
[root@instance-6lf3j8lp Python-3.7.0]# pipenv --version
-bash: pipenv: command not found
原因:未建立软链接
解决方案:
ln -s /usr/local/python3/bin/pipenv /usr/bin/pipenv