将完整的virtualenv复制到另一台PC [英] Copy complete virtualenv to another pc
问题描述
我在/home/user/virtualenvs/Environment
上有一个virtualenv
.现在,我需要在另一台PC上使用此环境.因此,我安装了virtualenv-clone
并将其用于克隆/Environment
.然后,我通过USB将其复制到另一台PC.我可以用source activate
激活它,但是当我尝试用sudo ./Environment/bin/python
启动python解释器时,我得到了
I have a virtualenv
located at /home/user/virtualenvs/Environment
. Now I need this environment at another PC. So I installed virtualenv-clone
and used it to clone /Environment
. Then I copied it to the other PC via USB. I can activate it with source activate
, but when I try to start the python interpreter with sudo ./Environment/bin/python
I get
./bin/python: 1: ./bin/python: Syntax Error: "(" unexpected
在没有sudo的情况下执行它会给我一个错误,告诉我二进制文件格式中有一个错误.
但是怎么可能呢?我只是复制了它.还是有更好的方法来做到这一点?我不能只使用pip freeze
,因为/Environment/lib/python2.7/site-packages/
中有一些我自己写的程序包,我也需要复制它们.据我了解,pip freeze
只是创建一个软件包列表,然后pip下载并安装.
Executing it without sudo gives me an error telling me that there is an error in the binaries format.
But how can this be? I just copied it. Or is there a better way to do this? I can not just use pip freeze
because there are some packages in /Environment/lib/python2.7/site-packages/
which I wrote myself and I need to copy them, too. As I understand it pip freeze
just creates a list of packages which pip then downloads and installs.
推荐答案
在源计算机上执行以下步骤:
- workon [environment_name]
- 冻结冻结> requirements.txt
- 将requirements.txt复制到另一台PC
在另一台PC上:
- 使用mkvirtualenv [environment_name]创建虚拟环境
- workon [environment_name]
- pip install -r requirements.txt
您应该完成.
这篇关于将完整的virtualenv复制到另一台PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!