将完整的virtualenv复制到另一台PC [英] Copy complete virtualenv to another pc

查看:761
本文介绍了将完整的virtualenv复制到另一台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.

推荐答案

在源计算机上执行以下步骤:

  1. workon [environment_name]
  2. 冻结冻结> requirements.txt
  3. 将requirements.txt复制到另一台PC

在另一台PC上:

  1. 使用mkvirtualenv [environment_name]创建虚拟环境
  2. workon [environment_name]
  3. pip install -r requirements.txt

您应该完成.

这篇关于将完整的virtualenv复制到另一台PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆