无法将Python venv克隆到另一台PC [英] Unable to clone Python venv to another PC

查看:281
本文介绍了无法将Python venv克隆到另一台PC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将现有的venv克隆到另一台PC,但是复制粘贴不起作用.当我复制venv并粘贴到第二台机器并运行

I want to clone my existing venv to another PC but simply copy paste is not working. When I copy the venv and paste to the second machine and run

点列表

它仅列出pip和setup_tools作为已安装的依赖项. 我尝试了另一种克隆软件包的方法. 我在第二台计算机中创建了一个新的venv,并跳过了新venv中具有相同名称的现有文件,将第一个venv的所有文件复制到了该新venv.现在,当我跑步

It only list pip and setup_tools as the installed dependencies. I tried another way to clone the packages. I created a new venv in the second machine and copied all the file of first venv to that new venv with skipping the existing files with the same name in new venv. Now, when I run

点列表

它显示了所有依赖项,但是,当我尝试以以下方式启动jupyter笔记本时

It shows all the dependencies but, when I try to launch the jupyter notebook as

jupyter笔记本

jupyter notebook

出现以下错误.

启动器中出现致命错误:无法使用" f:\ path \ to \ first_venv \ on_first_machine \ scripts \ python.exe"创建进程 "C:\ path \ to \ new_venv \ on_the_second_machine \ Scripts \ jupyter.exe"笔记本":系统找不到指定的文件.

Fatal error in launcher: Unable to create process using '"f:\path\to\first_venv\on_first_machine\scripts\python.exe" "C:\path\to\new_venv\on_the_second_machine\Scripts\jupyter.exe" notebook': The system cannot find the file specified.

我不知道如何使事情正常.请帮忙!

修改

问题是我的第二台计算机上没有互联网连接.实际上,这是一台应用了某些安全协议的远程计算机,而没有Internet连接是安全的一部分!我的坏人:'(

The problem is I don't have internet connection on the second machine. Actually it's a remote machine with some security protocols applied and having no internet connection is part of security ! My bad :'(

推荐答案

您无法将venv从一台机器复制粘贴到另一台机器,因为其中的脚本可能指向系统位置. (这表示尝试在机器内移动静脉).

You can't copy-paste venvs from one machine to another since scripts in them may refer to system locations. (The same stands for attempting to move venvs within a machine.)

相反,请在新计算机上重新创建环境:

Instead, recreate the environment on the new machine:

  1. 在旧计算机上,在virtualenv中运行pip freeze -l > packages.txt.
  2. packages.txt移到新计算机上.
  3. 在新计算机上创建一个新的virtualenv并输入它.
  4. 从txt文件中安装软件包:pip install -r packages.txt.
  1. On the old machine, run pip freeze -l > packages.txt in the virtualenv.
  2. Move packages.txt over to the new machine.
  3. Create a new virtualenv on the new machine and enter it.
  4. Install the packages from the txt file: pip install -r packages.txt.

编辑:如果第二台计算机上没有互联网访问权限,则可以通过以下步骤从步骤2继续:

If you don't have internet access on the second machine, you can continue from step 2 with:

  1. 在第一台计算机的venv中运行pip wheel -w wheels -r packages.txt.这将为您所需的所有软件包下载并构建*.whl软件包.请注意,这是假设两台机器的操作系统和体系结构都相似!
  2. 将wheel文件复制到新机器上.
  3. 在新计算机上创建一个新的virtualenv并输入它.
  4. 通过轮子在新的virtualenv中安装软件包:pip install *.whl.
  1. Run pip wheel -w wheels -r packages.txt in the venv on the first machine. This will download and build *.whl packages for all the packages you require. Note that this assumes both machines are similar in OS and architecture!
  2. Copy the wheel files over to the new machine.
  3. Create a new virtualenv on the new machine and enter it.
  4. Install the packages from wheels in the new virtualenv: pip install *.whl.

这篇关于无法将Python venv克隆到另一台PC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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