安装 python3.7
- 下载安装包
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
- 安装
./configure # 默认安装到 /usr/local 目录下
./configure --enable-optimizations --prefix=/opt/python3.7 # 或者指定安装路径 /opt/python3.7
make
sudo make install
- 将 Python3 的软链接指向 Python3.7
sudo rm /usr/bin/python3
sudo rm /usr/bin/pip3
sudo ln -s /opt/python3.7/bin/python3.7 /usr/bin/python3
sudo ln -s /opt/python3.7/bin/pip3 /usr/bin/pip3注:
- 默认路径安装(./configure)
- 可执行文件路径 /usr/local/bin
- 库文件路径 /usr/local/lib
- 配置文件路径 /usr/local/include
- 资源文件路径 /usr/local/share
- 指定路径安装(./configure --enable-optimizations --prefix=/opt/python3.7)
- 可执行文件路径 /opt/python3.7/bin
- 库文件路径 /opt/python3.7/lib
- 配置文件路径 /opt/python3.7/include
- 资源文件路径 /opt/python3.7/share
修复安装后 Terminal 打不开
- 安装后发现 Terminal 打不开,进入 Xterm,输入 gnome-terminal,出现如下图所示的错误:
- 修复方法
- 首先进入命令行模式,有两种方法:一种是在某个文件夹下右键打开终端,另一种是 Alt + Ctrl + F1 进入命令行界面,退回图形化界面用 Ctrl + Alt + F7;
- 然后执行以下命令:
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
- 将 gi 模块拷贝到安装路径(如 /opt/python3.7)下的对应目录
sudo cp -r /usr/lib/python3/dist-packages/gi /opt/python3.7/lib/python3.7/site-packages/