THE FOUNDER’S GUIDE:

How to Install and Manage Multiple Python Versions on Linux

The condensed tutorial with copy and paste code and screenshots

David Littlefield
6 min readFeb 27, 2021
Image by Isabella and Louisa Fischer

“The expanded version of this article uses concise explanations to help you learn what’s happening 💡”

Open Terminal:

  1. Click “Activities” in the top-left corner
  2. Enter “Terminal” into the search bar
  3. Click “Terminal”

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
python --version

Check the Executable File:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
which python

Open the Home Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
cd $HOME

Install Git:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
sudo apt-get install --yes git

Clone the Pyenv Repository:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Open the Bash Configuration File:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
gedit .bashrc

Edit the Bash Configuration File:

  1. Copy the code from below these instructions
  2. Paste the code into Text Editor
  3. 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:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
exec $SHELL

Update the Source List and Source List Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
sudo apt-get update --yes

Install the Pyenv Dependencies:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. 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:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
pyenv install --list

Install Python:

  1. Find the version from below these instructions
  2. Copy the provided command
  3. Paste the command into Terminal
  4. Press “Enter”
  5. Repeat
Python 3.5:
pyenv install 3.5.4
Python 3.6:
pyenv install 3.6.8
Python 3.7:
pyenv install 3.7.9
Python 3.8:
pyenv install 3.8.6
Python 3.9:
pyenv install 3.9.0

Set the Default Version for the Computer:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
pyenv global 3.8.6

Create the Temporary Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
mkdir temporary

Open the Temporary Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
cd temporary

Set the Default Version for the Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
pyenv local 3.6.8

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
python --version

Open the Parent Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
cd ..

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
python --version

Open the Temporary Directory:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
cd temporary

Create the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
python -m venv venv36

Activate the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
source ./venv36/bin/activate

Check the Default Version:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
python --version

Check the Executable File:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. Press “Enter”
which python

Deactivate the Virtual Environment:

  1. Copy the command from below these instructions
  2. Paste the command into Terminal
  3. 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 Learning
WSL2:
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 Learning
Mac:
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

--

--

David Littlefield
David Littlefield

Written by David Littlefield

From: Non-Technical | To: Technical Founder | Writes: To Make It Easier For Everyone | Topics: #Startups #How-To #Coding #AI #Machine Learning #Deep Learning

No responses yet