Dependencies
Install python3, python3-dev, and python3-pip.
Virtual environment
First, install virtualenv:
sudo -H pip3 install -U virtualenv
# H sets the HOME environment variable to the home directoryTo activate the new virtual environment, create (or navigate) a project directory, and call the virtualenv command:
mkdir MyPythonApp
cd MyPythonApp
virtualenv CustomPythonEnvNow, activate the virtual environment using:
# The script requires BASH
source CustomPythonEnv/bin/activateThe command prompt should now contain (venv)
Keep it clean
Virtual environments are a good way to keep the environment clean, making it easy to track installed packages. If you're developing, you may want to keep your packages on the same version. To do that, you can:
pip3 freeze > requirements.txtThat command will also create the requirements.txt file, that will contain a
list of the packages installed and their versions.
Now, if you need to replicate that same virtual environment, you can simply:
pip3 install -r requirements.txtDeactivation
After you're done, deactivate the virtual environment, simply calling:
deactivate