Ubuntu是另外一个广泛使用的Linux发行版本,本文将介绍如何在AWS的Ubuntu 16和Ubuntu 18镜像基础之上,安装Python3.6的开发环境。
AWS官方提供了两个不同Ubuntu的镜像。
官方的Ubuntu镜像
Ubuntu 16
CentOS.org提供的CentOS6是CentOS 6.10(Final)。登录CentOS之后,可以执行以下命令查看CentOS的版本。
Ubuntu 16已经默认安装了Python 3.5.2,我们需要在保留Python3.5.2的基础之上安装Python3.6,否则Ubuntu 16的某些功能无法正常运行。
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
具体的安装过程如附图所示:
设置APT源
Update APT源
安装并配置Python 3.6
执行完上述的操作后,Python3.6.8就安装成功了。同样的,我们建议建立虚拟工作环境。
python3.6 -m venv dev
source ./dev/bin/activate
Ubuntu 18
Ubuntu 18默认已经安装了Python 3.6.8,因此不需要单独安装Python3.6.8。
默认的Python3
但是我们需要通过以下命令安装pip和venv。
sudo apt-get update
sudo apt install python3-pip
sudo apt install python3-venv
更新APT源
安装pip
安装venv并创建DEV环境
完成上述的安装后,我们就可以建立一个工作环境。
python -m venv dev
source ./dev/bin/activate
Ubuntu is another widely used Linux distribution. This article will introduce how to install Python 3.6 development environment on AWS Ubuntu 16 and Ubuntu 18 images.
AWS officially provides two different Ubuntu images.
Official Ubuntu Images
Ubuntu 16
Ubuntu 16 comes with Python 3.5.2 installed by default. We need to install Python 3.6 while preserving Python 3.5.2, otherwise some features of Ubuntu 16 will not work properly.
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
The specific installation process is shown in the attached figure:
Set APT Repository
Update APT Repository
Install and Configure Python 3.6
After completing the above operations, Python 3.6.8 is successfully installed. Similarly, we recommend creating a virtual working environment.
python3.6 -m venv dev
source ./dev/bin/activate
Ubuntu 18
Ubuntu 18 already has Python 3.6.8 installed by default, so there is no need to install Python 3.6.8 separately.
Default Python3
However, we need to install pip and venv with the following commands.
sudo apt-get update
sudo apt install python3-pip
sudo apt install python3-venv
Update APT Repository
Install pip
Install venv and Create DEV Environment
After completing the above installation, we can create a working environment.
python -m venv dev
source ./dev/bin/activate