Linux下安装python3.6

主要是使用python3写的脚本,目前机器中默认使用的是python2,如果强行覆盖安装,则最直接的yum就无法使用了。

一、安装依赖包

 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

二、下载python包

https://www.python.org/downloads/

wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz

三、创建安装目录

mkdir /usr/local/python3

四、解压并安装

tar xf Python-3.6.6.tgz
cd Python-3.6.6/
./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
# python3 -V
Python 3.6.6
# pip3 -V
pip 10.0.1 from /usr/local/python3/lib/python3.6/site-packages/pip (python 3.6)

 指定源安装软件

pip3 install pexpect -i https://mirrors.aliyun.com/pypi/simple/

# 阿里云
https://mirrors.aliyun.com/pypi/simple/ 
# 清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
# 中国科技大学
https://pypi.mirrors.ustc.edu.cn/simple/ 
# 豆瓣
http://pypi.douban.com/simple 
# Python官方
https://pypi.python.org/simple/ 
# v2ex
http://pypi.v2ex.com/simple/ 
# 中国科学院
http://pypi.mirrors.opencas.cn/simple/ 

 

posted @ 2019-09-09 13:48  林中龙虾  阅读(1143)  评论(0)    收藏  举报