Linux下载、配置python环境
Linux下载、配置python环境刚刚把java环境配了,现在配python环境因为centos7自带python2的环境所以我们需要更新一下系统自带的版本python官网:https://www.python.org1. 进入/opt/software-install,使用wget命令下载python[root@cx software-install]# wget https://www.py
·
Linux下载、配置python环境
刚刚把java环境配了,现在配python环境
因为centos7自带python2的环境
所以我们需要更新一下系统自带的版本
python官网:https://www.python.org
1. 进入/opt/software-install,使用wget命令下载python
[root@cx software-install]# wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
[root@cx software-install]# ls
jdk-8u221-linux-x64.rpm Python-3.6.3.tgz
2. 解压到/opt/software下,更名为python
[root@cx software-install]# tar -zxvf Python-3.6.3.tgz -C /opt/software
[root@cx software]# ls
java python
3. 进入到python目录下,安装配置
[root@cx python]# ./configure
等待执行完毕
4. 编译并安装
[root@cx python]# make
[root@cx python]# make install
5. 查看python3安装的位置
[root@cx python]# ll /usr/local/bin/python*
lrwxrwxrwx 1 root root 9 Nov 11 22:13 /usr/local/bin/python3 -> python3.6
-rwxr-xr-x 2 root root 12650320 Nov 11 22:12 /usr/local/bin/python3.6
lrwxrwxrwx 1 root root 17 Nov 11 22:13 /usr/local/bin/python3.6-config -> python3.6m-config
-rwxr-xr-x 2 root root 12650320 Nov 11 22:12 /usr/local/bin/python3.6m
-rwxr-xr-x 1 root root 3097 Nov 11 22:13 /usr/local/bin/python3.6m-config
lrwxrwxrwx 1 root root 16 Nov 11 22:13 /usr/local/bin/python3-config -> python3.6-config
[root@cx python]# which python
/usr/bin/python
[root@cx python]# ll /usr/bin/python*
lrwxrwxrwx 1 root root 22 Nov 11 22:20 /usr/bin/python -> /usr/local/bin/python3
lrwxrwxrwx 1 root root 9 Jul 11 2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 7216 Jun 21 2019 /usr/bin/python2.7
-rwxr-xr-x 1 root root 1835 Jun 21 2019 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root 16 Jul 11 2019 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 7 Jul 11 2019 /usr/bin/python.bak -> python2
lrwxrwxrwx 1 root root 14 Jul 11 2019 /usr/bin/python-config -> python2-config
这里我已经配置好了,所以可以看到我的软链接已经指向我新的python3,旧的话应该指的是python2
6. 备份原有配置,设置python默认版本号为3.x
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python
7. 这里使用python -V可以看到版本为python3了
8. 查看python2的位置
[root@cx python]# ll /usr/bin/python*
lrwxrwxrwx 1 root root 22 Nov 11 22:20 /usr/bin/python -> /usr/local/bin/python3
lrwxrwxrwx 1 root root 9 Jul 11 2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 7216 Jun 21 2019 /usr/bin/python2.7
-rwxr-xr-x 1 root root 1835 Jun 21 2019 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root 16 Jul 11 2019 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root 7 Jul 11 2019 /usr/bin/python.bak -> python2
lrwxrwxrwx 1 root root 14 Jul 11 2019 /usr/bin/python-config -> python2-config
9. 为了使yum命令正常使用,需要将其配置的python依然指向2.x版本
/usr/bin/yum
/usr/libexec/urlgrabber-ext-down
将上面两个文件的头部文件修改为老版本即可
!/usr/bin/python 修改成 !/usr/bin/python2.7
更多推荐
已为社区贡献1条内容
所有评论(0)