THE FOUNDER’S GUIDE:
How to Install and Manage Multiple Python Versions on Linux
The condensed tutorial with copy and paste code and screenshots
“The expanded version of this article uses concise explanations to help you learn what’s happening 💡”
Open Terminal:
- Click “Activities” in the top-left corner
- Enter “Terminal” into the search bar
- Click “Terminal”
Check the Default Version:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python --version
Check the Executable File:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
which python
Open the Home Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
cd $HOME
Install Git:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
sudo apt-get install --yes git
Clone the Pyenv Repository:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
Open the Bash Configuration File:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
gedit .bashrc
Edit the Bash Configuration File:
- Copy the code from below these instructions
- Paste the code into Text Editor
- Click “Save”
# Pyenv environment variables
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"# Pyenv initialization
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
Restart Bash:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
exec $SHELL
Update the Source List and Source List Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
sudo apt-get update --yes
Install the Pyenv Dependencies:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
sudo apt-get install --yes libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libgdbm-dev lzma lzma-dev tcl-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev wget curl make build-essential python-openssl
View the Python Versions:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
pyenv install --list
Install Python:
- Find the version from below these instructions
- Copy the provided command
- Paste the command into Terminal
- Press “Enter”
- Repeat
Python 3.5:
pyenv install 3.5.4Python 3.6:
pyenv install 3.6.8Python 3.7:
pyenv install 3.7.9Python 3.8:
pyenv install 3.8.6Python 3.9:
pyenv install 3.9.0
Set the Default Version for the Computer:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
pyenv global 3.8.6
Create the Temporary Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
mkdir temporary
Open the Temporary Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
cd temporary
Set the Default Version for the Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
pyenv local 3.6.8
Check the Default Version:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python --version
Open the Parent Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
cd ..
Check the Default Version:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python --version
Open the Temporary Directory:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
cd temporary
Create the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python -m venv venv36
Activate the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
source ./venv36/bin/activate
Check the Default Version:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
python --version
Check the Executable File:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
which python
Deactivate the Virtual Environment:
- Copy the command from below these instructions
- Paste the command into Terminal
- Press “Enter”
deactivate
“Hopefully, this article helped you get the 👯♀️🏆👯♀️, remember to subscribe to get more content 🏅”
Next Steps:
This article is part of a mini-series that helps readers set up everything they need to start learning about artificial intelligence, machine learning, deep learning, and or data science. It includes articles that contain instructions with copy and paste code and screenshots to help readers get the outcome as soon as possible. It also includes articles that contain instructions with explanations and screenshots to help readers learn about what’s happening.
Linux:
01. Install and Manage Multiple Python Versions
02. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
03. Install the Jupyter Notebook Server
04. Install Virtual Environments in Jupyter Notebook
05. Install the Python Environment for AI and Machine LearningWSL2:
01. Install Windows Subsystem for Linux 2
02. Install and Manage Multiple Python Versions
03. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
04. Install the Jupyter Notebook Server
05. Install Virtual Environments in Jupyter Notebook
06. Install the Python Environment for AI and Machine Learning
07. Install Ubuntu Desktop With a Graphical User Interface (Bonus)Windows 10:
01. Install and Manage Multiple Python Versions
02. Install the NVIDIA CUDA Driver, Toolkit, cuDNN, and TensorRT
03. Install the Jupyter Notebook Server
04. Install Virtual Environments in Jupyter Notebook
05. Install the Python Environment for AI and Machine LearningMac:
01. Install and Manage Multiple Python Versions
02. Install the Jupyter Notebook Server
03. Install Virtual Environments in Jupyter Notebook
04. Install the Python Environment for AI and Machine Learning