

To create the environment, type the following command. To make sure you are in your home directory, type the following command at the command line:.To create a custom Python environment using virtualenv, follow these steps: Because the environment is isolated, you do not have to worry about other programs installing incompatible versions or otherwise breaking the application's configuration. This means you can install any specific versions that an application may require. A custom environment has its own installation directories, Python executables, packages, and modules. The virtualenv program allows you to create your own custom Python environments. Using virtualenv to create and activate an environment Follow the procedures below to set up your Python environments. For VPS and Dedicated server accounts, the Python Selector is not available.For information about how to use the Python Selector, please see this article. On shared and reseller hosting accounts, you should use the Python Selector instead to install and manage Python environments.

These lines are executed when you activate the virtual environment.

Setup: $ cat $VIRTUAL_ENV/bin/postactivateĬoncerning the standard venv package, here is a solution that: So if that is at all probable you could record the previous value somewhere temporary then read it back in on deactivate. Remember that if using this for environment variables that might already be set in your environment then the unset will result in them being completely unset on leaving the virtualenv. # This hook is run before this virtualenv is deactivated. To clean up symmetrically you can add to $VIRTUAL_ENV/bin/predeactivate. When you deactivate the virtualenv, the environment variable will persist. Remember that this wont clean up after itself. You could even automate the creation of the symlinks each time you use mkvirtualenv. env/postactivate $VIRTUAL_ENV/bin/postactivate If you want to keep this configuration in your project directory, simply create a symlink from your project directory to $VIRTUAL_ENV/bin/postactivate. # This hook is run after this virtualenv is activated. In case you're using virtualenvwrapper (I highly recommend doing so), you can define different hooks (preactivate, postactivate, predeactivate, postdeactivate) using the scripts with the same names in $VIRTUAL_ENV/bin/.
