CentOS6.5安装python3.7
1、下载python3
wget https://npm.taobao.org/mirrors/python/3.7.12/Python-3.7.12.tgz
2、解压
tar -xzvf Python-3.7.12.tgz
3、先建一个编译目录
mkdir /usr/local/python3
4、Python3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可。
yum install -y libffi-devel
5、然后编译、安装
cd Python-3.7.12./configure --prefix=/usr/local/python3makemake install这种是带openssl模块安装的方式./configure--prefix=/usr/local/python3 --with-openssl=/usr/local/openssl-1.1.1l
6、建立软链接:
ln -s /usr/local/python3/bin/python3 /usr/bin/python3ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
7、查看版本:
python3 -V
Mac安装python3.7
brew install pyhton@3.7
Python has been installed as/usr/local/opt/python@3.7/bin/python3Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to`python3`, `python3-config`, `pip3` etc., respectively, have been installed into/usr/local/opt/python@3.7/libexec/binYou can install Python packages with/usr/local/opt/python@3.7/bin/pip3 install <package>They will install into the site-package directory/usr/local/lib/python3.7/site-packagesSee: https://docs.brew.sh/Homebrew-and-Pythonpython@3.7 is keg-only, which means it was not symlinked into /usr/local,because this is an alternate version of another formula.If you need to have python@3.7 first in your PATH, run:echo 'export PATH="/usr/local/opt/python@3.7/bin:$PATH"' >> ~/.zshrcFor compilers to find python@3.7 you may need to set:export LDFLAGS="-L/usr/local/opt/python@3.7/lib"For pkg-config to find python@3.7 you may need to set:export PKG_CONFIG_PATH="/usr/local/opt/python@3.7/lib/pkgconfig"
pip pip3 替换国内镜像源
1、创建配置文件
~/.pip/pip.confmkdir -p ~/.piptouch ~/.pip/pip.conf
2、pip.conf文件内容
[global]timeout = 10index-url = http://mirrors.aliyun.com/pypi/simple/extra-index-url = https://pypi.org/simple/pip/[install]trusted-host = mirrors.aliyun.com
遇到的问题
SSLError
pip3报错安装python3.7.0后发现使用pip会出现如下报错:
https://blog.csdn.net/lkgCSDN/article/details/84403329 https://www.jianshu.com/p/8e476eef43f7
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.Collecting virtualenvRetrying (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.")) - skippingCould not find a version that satisfies the requirement virtualenv (from versions: )No matching distribution found for virtualenvpip 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
这时候需要升级系统的openssl:升级openssl
升级完毕重新编译安装 ./configure--prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
