python

Creating a Python Virtual Environment

STEP 1: Python

For Python 2, run the following command:

 # /remote/python/2.7.9/bin/virtualenv ~/projectDir

Or, for Python 3, run the following command:

 # /remote/python/3.4.2/bin/pyvenv ~/projectDir

Note that projectDir is the directory in which you will complete your project.

STEP 2: Activating Virtual Environment

Run the following command:

 # source ~/projectDir/bin/activate

Again, projectDir should be replaced with the appropriate directory.

Using pip (package manager)

Pip should be installed automatically when you create the virtual environment.

To update pip, run the following command:

 # pip install --upgrade pip

To search pip packages, run the following command:

 # pip search packageName 

Then, for example package requests:

 # pip search requests

To install a pip package, run the following command:

 # pip install packageName

Then, for example package requests:

 # pip install requests

Deactivating or deleting Python virtual environments

To deactivate your Python virtual environment, run the following command:

 # deactivate

To completely delete the Python virtual environment, run the following command:

 # rm -rf ~/projectDir/