Install python3.7+ on Ubuntu 16.04 to solve the terminal cannot open

In order to install to ordinary users, to avoid always sudo after-installation package, install it under /opt

# 将/opt 归属给普通用户ubuntu,看个人需求
$ sudo chown -R ubuntu /opt
$ wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
$ tar -xvzf Python-3.7.1.tgz
$ cd Python-3.7.1
# --prefix 表示安装到哪,如果想安装到默认目录就不要
$ ./configure  --enable-optimizations --prefix=/opt/python3.7
# 下面这个命令如果是带桌面的ubuntu记得用ubuntu自带terminal,
# 如果用xshell 需要下载xmanager
$ make && make install

After the installation is complete, you can change the original python3 of the system to the current 3.7, or not change it, just use troublesome, if you directly change the gnome-terminal, it will not open, this will be solved below.
I changed:

sudo rm  /usr/bin/python3
sudo rm  /usr/bin/pip3
sudo ln -s /opt/python3.7/bin/python3.7 /user/bin/python3
sudo ln -s /opt/python3.7/bin/pip3 /user/bin/pip3
# 升级下pip
$ pip3 install --upgrade pip

Then your gnome-terminal cannot be opened, because there is no _gisuch library, and then you can change the name of the library in the original system

cd /usr/lib/python3/dist-packages/gi/
# 下面的35 改成37 表示从py3.5 改到py3.7,如果安装的是3.6就改成36
sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so  _gi_cairo.cpython-37m-x86_64-linux-gnu.so
sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-37m-x86_64-linux-gnu.so

Well, if you did not install the python to /optthe next but the default directory, this should be just fine, if you install my way, it was found that no work, it will be reported when the package wrong path, put the entire gicopy to /opt/python3.7the next The corresponding directory is OK

$ cp -r /usr/lib/python3/dist-packages/gi /opt/python3.7/lib/python3.7/site-packages/

Guess you like

Origin blog.csdn.net/Fei20140908/article/details/88168690