Ubuntu 16.04安装Python3.7 & pip3

 1. Install Python3.7

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.7

2. Change Python3.7 as default

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 150

3. Install pip for Python3.7

sudo apt install python3-pip

 4. Verify pip version

pip3 -v

问题

1. Ctrl+Alt+T 无法启动 Teminal

Input : $ gnome-terminal

Error :
Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in 
    from gi.repository import GLib, Gio
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in 
    from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/__init__.py)

解决办法:(37m对应安装的Python版本) 

cd /usr/lib/python3/dist-packages/gi/
sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-37m-x86_64-linux-gnu.so
sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-37m-x86_64-linux-gnu.so

2. ModuleNotFoundError: No module named 'apt_pkg'

 File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 27, in 
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

解决方法:

/usr/lib/python3/dist-packages# 
sudo cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so

 

你可能感兴趣的:(Ubuntu)