Skip to content Skip to sidebar Skip to footer

Exporting A Conda Environment With Local Pip Installs

I have exported my currently active environment with conda env export > environment.yml This is very convenient since it keeps track of both conda and pip installed packages.

Solution 1:

There's no way to actually get it to create entries for the .whl file automatically from what I'm aware of.

The simplest way to get this to work is by manually altering the environment.yml file and adding the .whl file in the list under - pip:. I tried this by downloading the .whl package for nose and placing it in the same directory as my env.yml file, the structure looked like this:

name: python3_test
dependencies:
- openssl=1.0.2h=1- pip=8.1.2=py35_0- python=3.5.1=5- readline=6.2=2- setuptools=23.0.0=py35_0- sqlite=3.13.0=0- tk=8.5.18=0- wheel=0.29.0=py35_0- xz=5.2.2=0- zlib=1.2.8=3- pip:
   - nose-1.3.7-py3-none-any.whl

If it is located in a different directory, just supply the directory. The path, of course, should be valid when issuing conda create env.

The pip command issued when running conda env create -n <name> -f <file.yml> is a pretty straightforward install so the semantics of installing with pip from the command line should be similar. Heck, you could even add the url for the .whl file in the requirements.yml and the installation would still go down smoothly. Again, keeping the rest the same and using the url for downloading nose:

- pip:
   - https://pypi.python.org/packages/15/d8/dd071918c040f50fa1cf80da16423af51ff8ce4a0f2399b7bf8de45ac3d9/nose-1.3.7-py3-none-any.whl#md5=3135984cc9cfcbe5d9c46e166d6743b0

Using any url shouldn't cause any issue.

Solution 2:

Here is a specific example of an environment.yml that uses a URL to link to wheel files from Christoph Gohlke's compiled packages for Windows:

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  - http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

Reference: https://stackoverflow.com/a/35245610/1493069

Post a Comment for "Exporting A Conda Environment With Local Pip Installs"