Search code examples
pythonpipyamlcondaenvironment

How to install local library with pip to a conda environment using environtment.yml file?


I want to set up an environment.myl file for a project's conda environment. I have a local package that I would normally use pip install -e . so I can work on the code locally. Is there a way to use pip to install this package with the env file?

I tried this based on something I found using install options with github links, but doesn't work.

name: foo
channels:
  - defaults
dependencies:
  - python=3.7
  - pip
  - pip:
    - /Users/me/projects/package/ --install-option="-e"

Solution

  • As the code shows, conda-env will copy the entries in the pip: YAML list and place them into a temporary pip requirements file. Hence, you should follow the Requirements File Format, namely,

    name: foo
    channels:
      - defaults
    dependencies:
      - python=3.7
      - pip
      - pip:
        - -e /Users/me/projects/package
    

    A quick test on a local package for me verified that the package installed and shows up in pip list -e.

    There is also an advanced-pip/ example in the repository that illustrates some additional options.