Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use multiple python virtual environments on same server

How can I deploy and host multiple python projects with different dependancies on the same server at the same time?

like image 801
Euphorbium Avatar asked Jan 22 '13 08:01

Euphorbium


People also ask

Can I create multiple virtual environment in Python?

Create a virtual environment for each project. Run each application (the first time you try to do this, each application will fail). Research and install the packages that you think you might need to successfully run each application. Successfully run each application.

How do I switch between virtual environments in Python?

Switching between two virtual environment is easy. You can run deactivate command and source the other virtual environment.

Can I install different versions of Python into virtual environments?

By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.


1 Answers

It's not true of course that only one virtualenv can be activated at once. Yes, only one can be active in a shell session at once, but your sites are not deployed via shell sessions. Each WSGI process, for example, will create its own environment: so all you need to do is to ensure that each wsgi script activates the correct virtualenv, as is (in the case of mod_wsgi at least) well documented.

like image 188
Daniel Roseman Avatar answered Sep 28 '22 12:09

Daniel Roseman