virtualenv

virtualenv is a tool to create isolated Python environments. On Whatbox, you could use virtualenv to install python packages that aren't included in the main global python installation.

Installation (Python 3)

Use these instructions if you are using a Python program or script that requires Python 3.

To execute the following commands you need to connect to your server via SSH.

  1. Download virtualenv:

     wget -O virtualenv-15.1.0.tar.gz https://github.com/pypa/virtualenv/archive/15.1.0.tar.gz
    
  2. Extract virtualenv:

     tar xvf virtualenv-15.1.0.tar.gz
    
  3. Create the Python 3 virtualenv.

     python3 virtualenv-15.1.0/virtualenv.py --system-site-packages ~/virtualenv3/
    

    Optionally, you use a different path besides ~/virtualenv3/. If you use a different path, make sure to replace ~/virtualenv3/ in any commands you may see on the Wiki.

  4. Activate virtualenv:

     source ~/virtualenv3/bin/activate
    
  5. (Optional) Remove the virtualenv installation files

     rm -r ~/virtualenv-15.1.0/ virtualenv-15.1.0.tar.gz
    

Installation (Python 2.7)

Use these instructions if you are using a Python program or script that requires Python 2.

To execute the following commands you need to connect to your server via SSH.

  1. Download virtualenv:

     wget -O virtualenv-15.1.0.tar.gz https://github.com/pypa/virtualenv/archive/15.1.0.tar.gz
    
  2. Extract virtualenv:

     tar xvf virtualenv-15.1.0.tar.gz
    
  3. Create the Python 2.7 virtualenv.

     python virtualenv-15.1.0/virtualenv.py --system-site-packages -p /usr/bin/python2.7 ~/virtualenv2/
    

    Optionally, you use a different path besides ~/virtualenv/. If you use a different path, make sure to replace ~/virtualenv in any commands you may see on the Wiki.

  4. Activate virtualenv:

     source ~/virtualenv2/bin/activate
    
  5. (Optional) Remove the virtualenv installation files

     rm -r ~/virtualenv-15.1.0/ virtualenv-15.1.0.tar.gz
    

Upgrading virtualenv

To upgrade your virtualenv, simply remove or rename ~/virtualenv/ and run the commands again. Please be careful to make sure that your programs and scripts do not store configuration files in this directory; if they do, move them out before deleting the directory, and move them back in when finished.