Python
Installing python
This document offers comprehensive guidelines for installing Python on Ubuntu. It discusses multiple installation methods, such as utilizing APT, Anaconda
, or pyenv
for Python version management. The document also provides detailed instructions for installing Anaconda
, setting up a virtual environment with Anaconda, and installing and configuring pyenv
for Python version and virtual environment management.
Installing python using apt
Before installing Python on Ubuntu, it is important to check if Python is already installed on your system. You can do this by running the following command:
If Python ^3.10
is not already installed, you have the option to use APT to install it on your system. To do so, please follow these steps:
To update the system repository list, use the following command:sudo apt install python3
To set up Python, install the required dependencies using the following command:sudo apt
Install the latest version of Python with the command:
(Recommended) Using Anaconda or pyenv
Instead of directly installing Python on your system, it is recommended to use Python version management tools like Anaconda or pyenv.
Installing python using anaconda
Anaconda is a software package that includes Python and R programming languages. It is widely used in scientific computing for various fields like data science, machine learning, and large-scale data processing.
If you are using Linux and want to use GUI packages, you will need to install additional dependencies for Qt.
To install the latest version of Anaconda, follow these steps:
Download the latest version of Anaconda from the official website:shasum -a 256
(Recommended) Ensure the integrity of the installer's data by verifying it with SHA-256. For additional details on hash verification, please refer to the documentation on cryptographic hash validation.
Install Anaconda by running the downloaded installer :
Update all packages in Anaconda
Set up a Python Virtual Environment using Anaconda :
Activate the virtual environment :
For more information on how to use Anaconda and its features, please refer to the official documentation.
Installing python using pyenv
Pyenv is a tool that enables you to conveniently handle multiple Python versions and virtual environments.
To configure pyenv, you can simply follow these steps :
Download pyenv using the following command:
Update pyenv to the latest version :
To ensure proper configuration, please add the necessary settings to your shell startup file (
~/.bashrc
,~/.zshrc
, etc.), based on your shell environment.For Bash :
For Zsh :
To install the Python version you want, you can use pyenv. First check the available Python versions using the command
pyenv install --list
. Then, install a specific version by running the appropriate command.To start, create a Python virtual environment and activate it :
To learn more about using pyenv
and its features, please refer to the official documentation.
Last updated