先更新一下yum:
yum update
安装开发工具和依赖包:
yum groupinstall "Development Tools"
yum -y install libffi-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel zlib*
下载 和安装python3
22 2019-02-18 14:41:53 cd /home
30 2019-02-18 14:48:15 mkdir arrow
31 2019-02-18 14:49:00 cd arrow
32 2019-02-18 14:49:34 mkdir Downloads
40 2019-02-18 14:50:17 cd Downloads/
41 2019-02-18 14:50:39 wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
42 2019-02-18 14:57:01 tar -xf Python-3.7.0.tar.xz
45 2019-02-18 14:57:39 cd /usr/local
46 2019-02-18 14:57:41 ls
47 2019-02-18 14:58:00 mkdir python3
48 2019-02-18 14:58:32 mv /home/arrow/Downloads/Python-3.7.0 python3
49 2019-02-18 14:58:45 cd python3/
50 2019-02-18 14:58:57 ls
51 2019-02-18 14:59:00 cd Python-3.7.0/
54 2019-02-18 15:02:56 ./configure --prefix=/usr/local/python3 --enable-optimizations
55 2019-02-18 15:03:25 make
56 2019-02-18 15:33:02 make install
这个时候系统的python默认是python2,需要做一些配置,以让系统指向python3
cd /usr/bin
[root@arrow bin]# ls py*
pydoc pygmentize python python2 python2.7
[root@arrow bin]# mv python python_old
[root@arrow bin]# ln -s /usr/local/python3/bin/python3.7 /usr/bin/python
[root@arrow bin]# ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip
[root@arrow bin]# ls py*
pydoc pygmentize python python2 python2.7 python_old
同时yum等相关程序依赖的是python2,需要进入其配置文件修改成python2:
疑似还要修改的有gnome-tweak-tool
,但我没有这个文件。。
刚刚改完就测试出问题:执行firewall-cmd报错
Traceback (most recent call last):
File “/usr/bin/firewall-cmd”, line 24, in
from gi.repository import GObject
ModuleNotFoundError: No module named ‘gi’
原因是还需要修改firewall的python指向python2:
[root@arrow bin]# vim firewall-cmd
[root@arrow bin]# vim /usr/sbin/firewalld
补充安装mysql时报错了,也是同样的问题
改一下报错文件,发现依然时依赖python2,改成python2就好了。