手记

Python3安装

一、安装编译环境
yum install -y gcc zlib zlib-devel python-devel libffi-devel python-setuptools sqlite-devel

二、下载Python3源码包以及OpenSSL源码包
https://www.python.org/ftp/python/
https://www.openssl.org/source/

三、解压以及编译安装
mkdir /usr/local/ssl
tar zxvf openssl-1.1.0g.tar.gz -C /usr/local/ssl && cd  /usr/local/ssl/openssl-1.1.0g && ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl --shared && make && make install
mv /usr/bin/openssl  /usr/bin/openssl.old
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
cp /usr/local/ssl/lib/libcrypto.so.1.1 /usr/local/lib64/
cp /usr/local/ssl/lib/libssl.so.1.1 /usr/local/lib64/
ln -s  /usr/local/lib64/libssl.so.1.1 /usr/local/lib64/libssl.so
在/etc/ld.so.conf文件中写入openssl库文件的搜索路径echo "/usr/local/lib64" >> /etc/ld.so.conf
运行ldconfig -v 使修改后的/etc/ld.so.conf生效
查看openssl版本  openssl version

mkdir /usr/local/python
tar zxvf Python-3.7.0a4.tgz && cd Python-3.7.0a4 &&  ./configure  --prefix=/usr/local/python && make && make install

四、修改默认Python版本
mv /usr/bin/python /usr/bin/python_bak && ln -s /usr/local/python/bin/python3.7 /usr/bin/python

五、回复默认Python版本
rm -rf /usr/bin/python
mv /usr/bin/python_bak /usr/bin/python

六、安装pip
1、安装setuptools
wget https://pypi.python.org/packages/41/5f/6da80400340fd48ba4ae1c673be4dc3821ac06cd9821ea60f9c7d32a009f/setuptools-38.4.0.zip#md5=3426bbf31662b4067dc79edc0fa21a2e && unzip setuptools-38.4.0.zip && cd setuptools-38.4.0 && python setup.py install
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 && python setup.py install

0人推荐
随时随地看视频
慕课网APP