How To Setup A Python Virtual Environment in Ubuntu 18.04

November 5, 2019 Liquid Web

In this video, we will do a walkthrough of how to set up a virtual environment on Ubuntu. 

Commands used:

apt-get update -y
apt-get install -y python3-venv
mkdir awesome_python_project
cd awesome_python_project
python3 -m venv awesome_venv
source awesome_venv/bin/activate
pip install -U setuptools pip
pip install termcolor
cat < <EOF > hello_colors.py

Snippet:
================================
#!/usr/bin/env python

import termcolor

for color in termcolor.COLORS.keys():
    print(termcolor.colored("Hello!", color))
EOF
================================

python hello_colors.py
deactivate
python3

 import termcolor:
================================
> > > import termcolor
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'termcolor'
================================


The related article for this article can be found here: https://www.liquidweb.com/kb/how-to-setup-a-python-virtual-environment-on-ubuntu-18-04/

For more information about this and other topics, visit us at https://www.liquidweb.com/kb/.
For more information on our current specials, visit: https://www.liquidweb.com/products/vps/

Video by: Justin Palmer

About the Author

Liquid Web

Liquid Web powers online content, commerce, and potential for SMB entrepreneurs and the designers, developers and digital agencies who create for them. Sign up for our newsletter to stay up to date with our latest content.

More Content by Liquid Web
Previous Video
How To Install Sci-kit Learn On Ubuntu 18.04
How To Install Sci-kit Learn On Ubuntu 18.04

In this tutorial, we are going to walk through how to install scikit-learn on an Ubuntu 18.04 server. We ar...

Next Video
How to Install PyTorch on Ubuntu
How to Install PyTorch on Ubuntu

In this video, we describe how to install PyTorch on a Ubuntu 16.04 server. PyTorch is a machine learning l...

Learn What Qualities to Look for in Your Next Host in Our New Guide!

Download Now