Conda: specify environment variable before creating env from YAML file

Viewed 813

I am creating a environment.yml file for the creation of a custom environment.

One of the package (which I install via pip) requires an environment variable to be set (namely MACOSX_DEPLOYMENT_TARGET=10.7 in order to make gcc happy).

How can I do that?

name: mypy27
channels:
  # Default distribution from Continuum/Anaconda
  - defaults
  # Conda forge distribution
  # https://conda-forge.org
  - conda-forge
dependencies:
  - python=2.7
  - anaconda
  - pip:
    - rootnumpy
    - git+https://mypackage.git#egg=mypackage

The key is to set the environment variable before rootnumpy installation is started.

1 Answers

Since Conda v4.9, you can define environment variables in your 'environment.yml' file:

name: foo
channels:
  - defaults
dependencies:
  - python
variables:
  MY_VAR: something
  OTHER_VAR: ohhhhya

See the documentation or this answer for more information.

Related