Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use same virtual environment on different computers

On my office computer, I've made virtualenv one-for-rule-them-all at the Dropbox folder. I want to use this environment both at work and at home. Is this possible? (currently I'm not successful)

like image 864
mr_bulrathi Avatar asked Feb 27 '16 16:02

mr_bulrathi


People also ask

Can virtual environment be shared?

Don't share virtual environments between projects If you have multiple projects that have roughly the same requirements, it might seem like a good idea to create a single virtual environment that both projects can share. Don't do it.

Can I move a virtualenv folder to another computer?

1 Answer. Kindly be informed that yes, it is possible to move it on the same platform. You can simply use --relocatable on an existing environment. But it will get changed based on the new location in order to call python and pip, etc.

Should I create a virtual environment for every project?

✔ Use a Separate Virtual Environment for Each ProjectIdeally, you should have one new virtual environment for every Python-based project you work on. The main purpose of this is to keep the dependencies of every project isolated from both the system and each other.


1 Answers

Look into using the relocatable option of virtualenv. For full documentation, see the virtualenv documentation on the subject.

One note of interest:

Also, this does not make your packages cross-platform. You can move the directory around, but it can only be used on other similar computers. Some known environmental differences that can cause incompatibilities: a different version of Python, when one platform uses UCS2 for its internal unicode representation and another uses UCS4 (a compile-time option), obvious platform changes like Windows vs. Linux, or Intel vs. ARM, and if you have libraries that bind to C libraries on the system, if those C libraries are located somewhere different (either different versions, or a different filesystem layout).

As an alternative to this approach, I would simply manage your project/setup dependencies with setup.py requirements (install_requires, setup_requires), or pip requirements.txt file. This is much more portable and cross-platform.

like image 178
Josh Avatar answered Oct 02 '22 09:10

Josh