setting an environment variable

2 views
Skip to first unread message

Martin Genet

unread,
Dec 23, 2020, 1:19:00 PM12/23/20
to Anaconda - Public
Hi all,

I'm trying to set an environment variable in a conda environment file. I need something like $CPATH = $CONDA_PREFIX/include/vtk-9.0.
I followed https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#setting-environment-variables and tried the following minimal yml:

name: test
variables:
     CPATH: $CONDA_PREFIX/include/vtk-9.0

But unfortunately $CONDA_PREFIX is no substituted. Does anyone know how to do this? Thank you!

Martin

David Kun

unread,
Jan 8, 2021, 8:33:24 PM1/8/21
to Anaconda - Public, martin...@polytechnique.edu
Hopefully, you've already figured this out.  It appears that setting the environment variable within a conda environment differs if you're on Linux or Windows.

For Windows, this snippet of commands worked for me

(test-env) C:\Users\aaa>conda activate test-env

(test-env) C:\Users\aaa>conda env config vars list

(test-env) C:\Users\aaa>conda env config vars set CPATH=%CONDA_PREFIX%\include\vtk-9.0
To make your changes take effect please reactivate your environment

(test-env) C:\Users\aaa>conda activate test-env

(test-env) C:\Users\aaa>conda env config vars list
CPATH = C:\Users\aaa\miniconda3\envs\test-env\include\vtk-9.0

For Linux (I'm using CentOS VM),

(test-env) [vagrant@localhost ~]$ conda env config vars list
(test-env) [vagrant@localhost ~]$ conda env config vars set CPATH=$CONDA_PREFIX/include/vtk-9.0
To make your changes take effect please reactivate your environment
(test-env) [vagrant@localhost ~]$ conda activate test-env
(test-env) [vagrant@localhost ~]$ conda env config vars list
CPATH = /home/vagrant/.conda/envs/test-env/include/vtk-9.0

I hope that I understood the problem and the above snippets helps.

Martin Genet

unread,
Jan 10, 2021, 4:43:42 PM1/10/21
to David Kun, Anaconda - Public
Thank you David.

I tried to do it through the yml file, but it did not work so well.

Defining them using conda env config vars set is definitely the way to go, even though it is one more line than my students have to run.

Thanks again!

Martin

Ray Donnelly

unread,
Jan 10, 2021, 5:58:37 PM1/10/21
to Anaconda - Public
You need to use an activation script

--
Community Discussion Forum for Anaconda
---
You received this message because you are subscribed to the Google Groups "Anaconda - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to anaconda+u...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/anaconda/4ab6b3a0-d4d0-4334-a3a9-bdef7ea162a8n%40continuum.io.
Reply all
Reply to author
Forward
0 new messages