create virtual environment based on other virtual environment with canopy

601 views Asked by At

In my company I have a setup where I have an original canopy distribution installed. Through some batch process a virtual environment is then created of that which contains additional python packages.

The virtual environment works fine from pycharm, however, I have the following problems:

  1. When starting pip or python from the command line, the original canopy installation seems to be started. Am I right in thinking that 'activating' the virtual environment simply means adjusting the path variables to folders of the virtual environment? How is this best done automatically? Does canopy or python provide a good script? I want pip to install packages to the virtual environment, which it currently doesn't.

  2. What is the best way to create a new virtual environment based on the virtual environment I already have?

I know that with anaconda this would all be easier, but my solution needs to be based on pure python or canopy.

1

There are 1 answers

2
pragman On

Not sure about your specific environment, but for python projects, I usually get by with

pip freeze > requirements.txt

to save the list of packages installed in a virtual environment to a file

and

pip install -r requirements.txt

to restore the packages on a new virtual environment.

I've used requirements.txt as the filename, but you can pretty much use any file name you want for this.