How to move complete Python environment to new PC with virtual environment

Answered

I have a workstation where I do most development with the JetBrains PyCharm community edition. (Great IDE!!!). OS: Win 7. My Python code uses several additional libraries to what comes with Python 2.7.1.1 as "standard".

I now need to test code on a laptop that also runs on OS: Win 7.

I tried to generate a virtual environment in File / Settings / project: / project interpreter (after clicking the star symbol).

 

However: none of the packages I installed with PIP after I installed the basic Python 2.7.11 environment became copied to the virtual environment.

So when I copied the virtual environment directory to my laptop win W7 and tried to point to that virtual environment, I got the usual error messages about missing libraries.

Question: how can I clone a python installation with all needed libraries from one PC to another PC running the same OS in PyCharm?

Why doesn't the "Create Virtual Environment" command copy also the libraries I have installed with PIP. I have tried with Inherit global site-packages on or off - no difference.

0
1 comment

From https://virtualenv.pypa.io/en/stable/userguide/:

Normally environments are tied to a specific path. That means that you cannot move an environment around or copy it to another computer. You can fix up an environment to make it relocatable with the command:

$ virtualenv --relocatable ENV

The --relocatable option currently has a number of issues, and is not guaranteed to work in all circumstances. It is possible that the option will be deprecated in a future version of virtualenv.

> Why doesn't the "Create Virtual Environment" command copy also the libraries I have installed with PIP. I have tried with Inherit global site-packages on or off - no difference.

Please, check https://youtrack.jetbrains.com/issue/PY-20540 and vote for it to increase its priority and be notified about updates.

We recommend using requirement files: https://pip.readthedocs.io/en/1.1/requirements.html, https://www.jetbrains.com/help/pycharm/2016.3/creating-requirement-files.html. Please, feel free to ask any questions.

0

Please sign in to leave a comment.