Linux Server Install: Part 14

Laxfed Paulacy
2 min readJan 6, 2023

Make sure you have a recent version of Python, bruh.

Previous

Install Python3.9

We’ll install Python 3.9 on our Ubuntu server and create a virtual environment named venv that is activated on startup.

Install the python3.9 and python3.9-venv packages:

sudo apt update && sudo apt install python3.9 python3.9-venv

Create a symbolic link from /usr/local/bin/python to /usr/bin/python3.9.

The /usr/local/bin directory is usually included in the PATH by default, so this will allow you to use the python command to run Python 3.9.

sudo ln -s /usr/bin/python3.9 /usr/local/bin/python

To verify that the python command is now linked to the desired version of Python, run the following command:

python --verison

Create the virtual environment:

python -m venv venv

This will create a virtual environment named venv in the current directory.

Automatically Activate the Environment

Activate the virtual environment:

source ~/venv/bin/activate

Open the .profile and add that command to the end so the environment is activated when you log in.

sudo nano ~/.profile

Exit and run:

source ~/.profile

Note

If you’re using zsh, you might need to add that line to the .zshrc file.

--

--

Laxfed Paulacy

Delivering Crypto Currency, Python Programming, and Federal Government Shenanigans and Content.