Search code examples
pythonanacondayamlcondavirtual-environment

Conda: syntax of the environment yaml file vs. venv requirements


I have a venv requirement text file that I used to create a virtual environment for pip.

I want to setup now an environment in conda, based on the requirement file for pip. However, there are few lines that I don't know how to "port" from pip to conda syntax. If I take lines like:

scipy>=1.4.1

and copy it this way into the conda yaml file:

dependencies:
    - scipy>=1.4.1

they work fine. But in the requirement files there are lines like:

openexr==1.3.2; platform_system == 'Linux'
dataclasses>=0.8; python_version == '3.6'

and if I try to copy those in the same way they give an error.

CondaValueError: invalid package specification: openexr==1.3.2; platform_system == 'Linux'

What's the proper syntax to "translate" those lines?


Solution

  • Conda will know your platform already, so the first line keeps only the openexr specification. For the second one, Conda manages Python, so that the Python version specification can be included explicitly on a separate line. Altogether, something like

    dependencies:
      - python=3.6
      - scipy>=1.4.1
      - openexpr=1.3.2
      - dataclasses>=0.8