Virtual Environment
Install all the necessary APT packages and set up a virtual environment.
We'll cover the following
Learn to set up a virtual environment with all the necessary dependencies.
A virtual environment helps to isolate all our dependencies based on our projects. We can easily replicate the same project on another machine.
Python
Installer
Python version 3.7 or above is recommended. Check the following webpage to learn how to download the installer and upgrade the existing version of Python. The newer versions ensure that we can install and run the scripts smoothly without any problems.
Note: All development and testing are based on Conda Python 3 environments on Linux x86-64 systems, specifically Python 3.6.x, 3.7.x., 3.8.x., and 3.9.
APT packages (Ubuntu)
For Ubuntu users, we can install other optional packages that are useful for development.
First, make sure that all of our packages are up-to-date by entering the following:
sudo apt update
Next, install the pip apt
package. We’ll use it to install Python-related packages later on.
sudo apt install -y python3-pip
There are other useful development packages that we can install. For example:
sudo apt install -y build-essential libssl-dev libffi-dev python3-dev
Virtual environment
It’s good practice to create a new virtual environment. It isolates our project and makes things easier later one.
We can easily install an apt
package that helps create virtual environments for us.
sudo apt install -y python3-venv
Use the instructions for your specific operating system.
Windows
Run the following command on the terminal:
python3 -m venv ./venv
It creates a new folder called venv
in our working directory. Modify the name to ./venv
.
Continue by activating it with the following command:
.\venv\Scripts\activate
Mac and Ubuntu
Run the following command to instantiate a new virtual environment:
python3 -m venv ./venv
Then, activate it via source
as follows:
source ./venv/bin/activate
Get hands-on with 1400+ tech skills courses.