Virtualenv is a powerful tool to create virtual python environments. Virtual python environments don't share installed packages with other environments. This is great if your applications require different versions of libraries.
Before we can install Virtualenv, let's run the commands below to install and update necessary packages.
sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential
We can either install virtualenv using apt-get or pip. To install Virtualenv using Ubuntu apt-get package manager, run the command below:
sudo apt-get install python-virtualenv
Alternatively, to install virtualenv using pip, run the commands below.
sudo apt-get install python-pip pip install virtualenv
To setup, a virtual python environment, run the commands below and replace "/pytest" with the directory where you want to create the virtualenv.
mkdir /pytest cd /pytest virtualenv .
Now we have the virtual environment setup, we can activate the virtualenv by using the following command.
source /pytest/bin/activate
Once you are done using the virtualenv, you can exit out of it by running:
deactivate
How to Setup Python Virtualenv on Ubuntu 14.04
Comments
Add comment