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

查看:31
本文介绍了无法将 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 notebook 启动为

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

jupyter 笔记本

jupyter notebook

它给出了以下错误.

启动器中的致命错误:无法使用f:path ofirst_venvon_first_machinescriptspython.exe"创建进程C:path o ew_venvon_the_second_machineScriptsjupyter.exe"notebook': 系统找不到指定的文件.

Fatal error in launcher: Unable to create process using '"f:path ofirst_venvon_first_machinescriptspython.exe" "C:path o ew_venvon_the_second_machineScriptsjupyter.exe" notebook': The system cannot find the file specified.

我不知道如何让事情发挥作用.请帮忙!

编辑

问题是我在第二台机器上没有互联网连接.实际上它是一台应用了一些安全协议的远程机器,没有互联网连接是安全的一部分!我的坏:'(

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 :'(

推荐答案

您不能将 venvs 从一台机器复制粘贴到另一台机器,因为其中的脚本可能会引用系统位置.(同样代表试图在机器内移动 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. 在旧机器上,运行 pip freeze -l >package.txt 在 vi​​rtualenv 中.
  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 Wheel -r packages.txt.这将为您需要的所有包下载并构建 *.whl 包.请注意,这假设两台机器在操作系统和架构上都相似!
  2. 将车轮文件复制到新机器上.
  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天全站免登陆