Coding in Python 23 – Virtual Environments

In video number 23 of the Coding in Python series, you’ll be introduced to the concept of Virtual Environments.

YouTube player

Commands Used in this Video

Install the required packages

sudo apt install python3-virtualenv

Create a virtual environment

virtualenv -p /usr/bin/python3 my-project

Activate the virtual environment

Change directory into the folder:

cd my-project
source bin/activate

Notice that your Python binary has changed

which python
which python3

Check Python version, to ensure using Python 3

python --version

Deactivate a virtual environment

deactivate

Using pip to install a package

pip install Flask

Listing packages installed via pip

pip list

Uninstalling a pip package

pip uninstall Flask

Check out the Shop!

Support Linux Learning and get yourself some cool Linux swag!


Support LearnLinuxTV and receive 5% off an LPI exam voucher!