CentOS7上Python-3-6的安装
文章发布较早,内容可能过时,阅读注意甄别。
# 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 wget gcc gcc-c++
1
# 2,下载源码并安装。
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xf Python-3.6.3.tgz
cd Python-3.6.3
./configure --prefix=/usr/local && make && make altinstall
1
2
3
4
2
3
4
# 3,更改 / usr/bin/python 链接
cd /usr/bin && mv python python.backup && ln -s /usr/local/bin/python3.6 /usr/bin/python &&ln -s /usr/local/bin/python3.6 /usr/bin/python3 && ln -s /usr/local/bin/pip3.6 /usr/bin/pip
1
# 4,更改两个依赖。
/usr/bin/yum
/usr/libexec/urlgrabber-ext-down
1
2
2
分别把两个文件的第一行尾部加上 2
#!/usr/bin/python 改为 #!/usr/bin/python2
sed -i '1s/python/python2/g' /usr/bin/yum
sed -i '1s/python/python2/g' /usr/libexec/urlgrabber-ext-down
1
2
3
4
2
3
4
# 5,验证。
[root@localhost bin]$python
Python 3.6.3 (default, May 24 2018, 16:45:02)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[root@localhost bin]$pip -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
1
2
3
4
5
6
7
2
3
4
5
6
7
上次更新: 2024/11/19, 23:11:42