Python virtual environment migration

environment

Introduction

When running some large-scale deep learning projects, the environment configuration often takes a large part of the time. If you encounter some version problems of dependent libraries, it may take longer. Wouldn’t it be a bit of a crash if you had to install it again on another machine? What if there are 10 machines? What if there is no network environment yet? This article introduces a method that can quickly realize the migration of the environment, which is conda-pack .

Practical

It is assumed here that there are 2 machines, the source machine and the target machine both use anaconda environment, and there is already a virtual environment called wav2lip in the source machine, and the dependency library needed to run the wav2lip project is installed in the environment. Now it is necessary to migrate wav2lip environment in the source machine to the target machine, so that the target machine can directly use this virtual environment and let the project run.

First, install the migration tool on the source machine

 pip install conda-pack

Then you can export, execute the command

 conda pack -n wav2lip

Among them, the -n parameter is followed by the name of the virtual environment. After exporting, it is a tar.gz file, which is a compressed package

After completion, copy tar.gz file to the target machine. If it is windows system, install a git for window , which is convenient to use the command under linux to decompress. The address is: https://gitforwindows.org/

After installation, right mouse button to open git bash , create a folder, then enter the folder, unzip

 mkdir wav2lip cd wav2lip tar xvf wav2lip.tar.gz

After completion, copy wav2lip to the virtual environment directory of anaconda , here is D:\Tools\anaconda3\envs

Finally, open cmd to verify

This article is transferred from https://xugaoxiang.com/2023/03/20/python-conda-env-migration/
This site is only for collection, and the copyright belongs to the original author.