Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
684 views
in Technique[技术] by (71.8m points)

jupyter notebook - Unable to clone Python venv to another PC

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 list

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

pip list

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

jupyter notebook

It gives the following error.

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

I don't know to make things working. Please help!

Edit

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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. 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.

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

  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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...