How to create a virtualenv by cloning the current local environment?
Asked Answered
S

3

10

Suppose I have a python interpreter with many modules installed on my local system, and it has been tuned to just work.

Now I want to create a virtualenv to freeze these, so that they won't be broke by upgrading in the future.

How can I make it? Thanks.


I can't use pip freeze, because that's a cluster on which there's no pip and I don't have the privileges to install it. And I don't want the reinstall the modules either, I'm looking for that whether there's a cloning way.

Scuttle answered 6/1, 2013 at 18:24 Comment(2)
@Marcin I searched on google and here but got nothing:-(Scuttle
You can install pip if you can write to files.Vast
P
8

Run pip freeze to create a list of all modules currently installed on the system. Then make a virtualenv and install these modules.

pip freeze > env_modules.txt
virtualenv my_env && cd my_env && source bin/activate
pip install -r ../env_modules.txt
Portsalut answered 6/1, 2013 at 18:29 Comment(2)
no, I can't use pip. That's a cluster on which I don't have the privileges to install anything, including pip itself. That's why I'm asking to clone, not to reinstall.Scuttle
@Jon Gauthier It does not work ((( When running command "pip install -r ../env_modules.txt" - it says for every package that: "Requirement already satisfied: asn1crypto==0.22.0 in c:\python34\lib\site-packages" So - it is using LOCAL packages and doesn't want to create a CLONE!!! Jon, can you please help with this problem?Sportswear
T
0

Virtualenv does not work because it uses local python interpreter.

My solution is to use conda (anoconda or miniconda) to build the environment, so if you need some packages, you can just conda install them. Then copy it to the remote machine and run.

Tension answered 20/6, 2018 at 0:12 Comment(0)
U
-3

I think the best is to use cpvirtualenv like this:

cpvirtualenv <name_of_virtualenv_to_be_copied> <name_of_new_virtualenv>
Unquestioning answered 9/12, 2016 at 5:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.