【python】--python2与py

2020-01-03 16:31:34 浏览数 (1)

python3 和python 2 共存

1.安装基础的系统包

(因为我是在docker下启动的Linux, p_w_picpath中很多包没有装)

yum install -y hostname  wget  tar passwd gcc lrzsz telnet passwd tar man vim make net-tools sudo  vixie-cron crontabs gcc gcc-c autoconf

2.安装python的依赖包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-deve libffi libffi-devel -y

3.下载

#国外地址

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

#国内地址

wget http://mirrors.sohu.com/python/3.4.3/Python-3.4.3.tgz

4.安装

tar -zxvf Python-3.4.3.tgz

cd Python-3.4.3

./configure --prefix=/usr/local/python3

make

make altinstall

echo /usr/local/lib >> /etc/ld.so.conf.d/local.conf

ldconfig

ln -s /usr/local/python3/bin/python3.4 /usr/bin/python3

5.安装后在

python程序的执行文件:/usr/local/bin/python3.4 

python应用程序目录:/usr/local/lib/python3.4 

pip的执行文件:/usr/local/bin/pip3.4

6.如果要安装其他包

python3 -m pip install  包名 

安装后在

/usr/local/lib/python3.4/site-packages

0 人点赞