Python环境搭建---centos 7.6

操作环境

服务器:阿里云 CentOS7.6.1810
时间: 20190213

安装依赖包

# yum -y groupinstall "Development tools"
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

创建一个安装包暂存目录 /usr/local/downloadtemp,然后获取python3.7.2的安装包

# mkdir /usr/local/downloadtemp
# cd /usr/local/downloadtemp
# wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz

下载完毕后,解压安装包,新建安装目标目录/usr/local/python3,然后开始安装

# tar -xvJf  Python-3.7.2.tar.xz
# mkdir /usr/local/python3
# cd /usr/local/downloadtemp/Python-3.7.2
# ./configure --prefix=/usr/local/python3
# make && make install

安装完毕后建立软连

# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

测试已经安装成功

# python -V
Python 2.7.5
# pip -V
pip 18.1 from /usr/lib/python2.7/site-packages/pip (python 2.7)
# python3 -V
Python 3.7.2
# pip3 -V
pip 18.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)

顺手更新下pip

# pip3 install --upgrade pip

你可能感兴趣的:(Python环境搭建---centos 7.6)