Ubuntu 18.04系统内置了Python 3.6和Python 2.7版本,以下是在Ubuntu 18.04系统中安装Python 3.7版本的方法。
执行所有升级
sudo apt update
sudo apt upgrade -y
安装编译Python源程序所需的包
sudo apt install build-essential -y
sudo apt install libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev -y
sudo apt-get install zlib1g-dev
后面的就不截图了,自己根据下面的指令进行操作即可!
下载Python 3.7源程序压缩包
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
解压缩
tar -xzvf Python-3.7.1.tgz
配置
cd Python-3.7.1
./configure --enable-optimizations
编译和安装Python 3.7
sudo make
sudo make install
查看Python版本
python3
Python 3.7.1 (default, Nov 21 2018, 16:35:49)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
升级pip和更换pip源
sudo pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install --upgrade pip