概述
获取资源
wget未安装:yum install wget -y
安装依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make -y
解压安装
[root@CentOS7 ~]# cd /usr/local/src/
[root@CentOS7 src]# tar -Jxvf Python-3.6.2.tar.xz
[root@CentOS7 src]# cd Python-3.6.2
[root@CentOS7 Python-3.6.2]# ./configure prefix=/usr/local/python3 && make && make install
链接
[root@CentOS7 Python-3.6.2]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@CentOS7 Python-3.6.2]# ll /usr/bin/py*
-rwxr-xr-x. 1 root root 78 Apr 11 2018 /usr/bin/pydoc
lrwxrwxrwx. 1 root root 7 Jul 5 11:00 /usr/bin/python -> python2
lrwxrwxrwx. 1 root root 9 Jul 5 11:00 /usr/bin/python2 -> python2.7
-rwxr-xr-x. 1 root root 7216 Apr 11 2018 /usr/bin/python2.7
lrwxrwxrwx. 1 root root 30 Nov 16 15:04 /usr/bin/python3 -> /usr/local/python3/bin/python3
或者设置默认为3版本,但是得修改yum配置
[root@CentOS7 Python-3.6.2]# vim /usr/bin/yum
#!/usr/bin/python 修改为 #!/usr/bin/python2
[root@CentOS7 Python-3.6.2]# vim /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python 也要修改为 #! /usr/bin/python2
配置pip
Python3装完后,默认已经安装了pip,此时只要配置下软链接即可使用pip工具:
[root@CentOS7 Python-3.6.2]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
最后
以上就是跳跃哈密瓜为你收集整理的linux同时安装python2和python3_linux下安装python3与python2共存的全部内容,希望文章能够帮你解决linux同时安装python2和python3_linux下安装python3与python2共存所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复