Ubuntu 18.04系统内置了Python 3.6和Python 2.7版本,以下是在Ubuntu 18.04系统中安装Python 3.7版本的方法。 1. 执行所有升级 sudo apt update sudo apt upgrade -y 2. 安装编译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 3. 下载Python 3.7源程序压缩包 wget https://www./ftp/python/3.7.1/Python-3.7.1.tgz 4. 解压缩 tar -xzvf Python-3.7.1.tgz 5. 配置 cd Python-3.7.1 ./configure --enable-optimizations 执行上述语句将启用代码的发布版本,可以优化二进制文件以更好的更快的运行,但是需要运行测试,编译时需要花费一些时间(大约半小时),也可以不进行这一项配置。 6. 编译和安装Python 3.7 sudo make sudo make install 7. 查看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. >>> 出现上述语句说明安装成功。 8. 升级pip和更换pip源 sudo pip config set global.index-url https://pypi.tuna./simple pip3 install --upgrade pip
|