linux系统下安装python3
python版本:Python-3.6.4.tar.xz
下载地址:https://www.python.org/downloads/release/python-364/ 选择XZ compressed source tarball进行下载
# yum install xz
1. 安装依赖环境---这个步骤很重要
# 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
2.安装python
安装在/usr/local/python3(具体安装位置看个人喜好)
创建目录:
# mkdir /usr/local/python3
将Python-3.6.4.tar.xz放入在/tmp目录下
# tar xvf xxx.tar Python-3.6.4.tar.xz 解压文件
# cd /tmp/Python-3.6.4
# ./configure --prefix=/usr/local/python3 配置安装位置
# make
# make instanll
3.建立软连接
# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
4.配置环境变量
# vi ~/.bash_profile
# PATH=
$PATH:$HOME
/
bin
:
/usr/local/python3/bin
# export PATH
5.让path生效
6.创建pip3软连接
7.有些人提到的setuptools等我们在安装virtualenv时候就已经一键添加了并不需要了。
Collecting pymysql
Downloading PyMySQL-0.8.0-py2.py3-none-any.whl (83kB)
100% |████████████████████████████████| 92kB 38kB/s
Installing collected packages: pymysql
Successfully installed pymysql-0.8.0
[root@promote Python-3.6.4]# ^C
[root@promote Python-3.6.4]#