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

查看:38
本文介绍了将完整的 virtualenv 复制到另一台电脑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位于 /home/user/virtualenvs/Environmentvirtualenv.现在我需要在另一台 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. 工作 [环境名称]
  2. pip freeze > requirements.txt
  3. 将 requirements.txt 复制到其他电脑

在另一台电脑上:

  1. 使用 mkvirtualenv [environment_name] 创建一个虚拟环境
  2. 工作 [环境名称]
  3. pip install -r requirements.txt

你应该完成了.

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

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