[2020 version] How to install Python3 on AWS EC2

The other day, I had the opportunity to install Python 3 on AWS EC2.

At that time, I did a Google search on "AWS EC2 Python3", but the information on the page displayed at the top of the search results was not good enough. In particular,

The method of preparing a virtual environment for Python3 was introduced using, but unless there are special circumstances, the method for preparing a virtual environment for Python3 should use venv. Also, unless you use Python3 for application development or data analysis, you don't need to prepare a virtual environment in the first place.

The reason for using venv as a way to prepare a virtual environment for Python 3 is [the only method recommended in the official Python documentation](https://docs.python.org/ja/3/library/venv. html) Because. The reason why you should avoid pyenv is described in detail in this article, so if you are interested, please see here.

Also, AWS official documentation introduces the method using virtualenv. , I don't think there is any reason to actively use virtualenv in Python 3.3 or later, which was officially incorporated into Python as venv.

So, I would like to introduce how to install Python3 on AWS EC2 again. That said, it just follows the method introduced in the official Python documentation ...

Premise

procedure

  1. Install Python 3 on the OS system

    $ sudo yum update
    $ sudo yum install python3 -y
    

Opportunities to use Python are limited, and I think this is sufficient if you don't need version control for Python itself or packages. On the other hand, if you want to manage the version for exclusive use in application development, or if you want to prepare an environment for exclusive use in data analysis, the virtual environment comes into play.

  1. Install Python3 for virtual environment using venv

    $ python3 -m venv myenv
    

If you execute the above command in your home directory, a directory called myenv will be created under your home directory. You can change the name myenv to your liking.

  1. Enable Python 3 virtual environment

    $ source myenv/bin/activate
    

Running the above command will enable the Python 3 virtual environment.

  1. Disable Python 3 virtual environment

    $ deactivate
    

If you want to exit the virtual environment of Python3, just execute the above command. Also, if you want to completely delete the environment, you can delete the myenv directory.

Finally

I introduced how to install Python3 on AWS EC2, but I think that is the case at least for Linux-based OS. Keep in mind that those who rarely use Python will use Python3 installed on the OS system, and those who use Python will use the Python3 virtual environment created using venv.

Recommended Posts

[2020 version] How to install Python3 on AWS EC2
[AWS EC2] How to install Maven on Amazon Linux 2
How to install Python
[Kivy] How to install Kivy on Windows [Python]
How to install python
How to install OpenCV on Jetson Nano Python
[Python] How to install OpenCV on Anaconda [Windows]
[2020.8 latest] How to install Python
How to install Python [Windows]
Tabpy 1.0 (2020-01 version) How to install
Python --Install MySQLDB on EC2
How to change Python version
How to install git on Linux such as EC2
How to install python using anaconda
How to install mysql-connector-python on mac
Install xgboost (python version) on Windows
How to install graph-tool on macOS
How to install VMware-Tools on Linux
How to install pycrypto on Windows
How to get the Python version
How to install OpenCV on Mac
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
How to install Maven on CentOS
Steps to install python3 on mac
How to install Go on Ubuntu
How to install music 21 on windows
[AWS SAM] Introduction to Python version
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
Building an environment to execute python programs on AWS EC2
[AWS EC2] How to install only MySQL client on Amazon Linux 2 and connect to RDS
How to install aws-session-manager-plugin on Manajro Linux
How to read pydoc on python interpreter
How to install drobertadams / toggl-cli on Mac
How to install and use pandas_datareader [Python]
python3 How to install an external module
Steps to install Python environment on Ubuntu
How to erase Python 2.x on Mac.
Memorandum on how to use gremlin python
How to check opencv version in python
How to install packages on Alpine Linux
How to install Anisble on Amazon Linux 2
How to install richzhang / colorization on Windows 10
How to install Apache (httpd) on CentOS7
Install python on xserver to use pip
How to install php7.4 on Linux (Ubuntu)
How to install Eclipse GlassFish 5.1.0 on CentOS 7
How to install Apache (httpd) on CentOS8
How to install NumPy on Raspberry Pi
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
How to install cx_Oracle on macOS Sierra
How to install python3 with docker centos
How to install OpenCV on Cloud9 and run it in Python
Things to note when running Python on EC2 from AWS Lambda
How to install pandas on EC2 (How to deal with MemoryError and PermissionError)
How to automatically install Chrome Driver for Chrome version with Python + Selenium + Chrome
How to update the python version of Cloud Shell on GCP
How to start Python (Flask) when EC2 starts
Install python on WSL
Install Python on Pidora.
Install Scrapy on python3