How to activate conda env from user directory?

04-06-2017 11:40 PM
Occasional Contributor

I'm using the conda environment that comes with ArcGIS Pro 1.4 (administrative install in C:\Program Files\ArcGIS\Pro).

So I open a cmd-shell and cd into C:\Program Files\ArcGIS\Pro\bin\Python\Scripts (running as normal Windows user, not as an administrative one).

Creating and listing a new conda env works just fine:

C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>conda create --name JebuTest python=3.5
Fetching package metadata: ......
Solving package specifications: .........

Package plan for installation in environment C:\Users\jebu\.conda\envs\JebuTest:

The following NEW packages will be INSTALLED:

    pip:            9.0.1-py35_1
    python:         3.5.3-0
    setuptools:     27.2.0-py35_1
    vs2015_runtime: 14.0.25123-0
    wheel:          0.29.0-py35_0

Proceed (/n)?

Linking packages ...
[      COMPLETE      ]|##################################################| 100%
# To activate this environment, use:
# > activate JebuTest

C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>conda info --envs
# conda environments:
JebuTest                 C:\Users\jebu\.conda\envs\JebuTest
arcgispro-py3            C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
root                  *  C:\Program Files\ArcGIS\Pro\bin\Python

As I'm not administrator, the environment installs into my user's home directory.

But if I try to activate the environment, it fails:

C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>activate JebuTest
No environment named "JebuTest" exists in C:\Program Files\ArcGIS\Pro\bin\Python\envs, or is not a valid conda installation directory.

Conda info also knows about my user's home directory:

C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>conda info
Current conda install:

             platform : win-64
        conda version : 4.0.11
  conda-build version : not installed
       python version :
     requests version : 2.11.1
     root environment : C:\Program Files\ArcGIS\Pro\bin\Python  (read only)
  default environment : C:\Program Files\ArcGIS\Pro\bin\Python
     envs directories : C:\Users\jebu\.conda\envs
                        C:\Program Files\ArcGIS\Pro\bin\Python\envs
        package cache : C:\Users\jebu\.conda\envs\.pkgs
                        C:\Program Files\ArcGIS\Pro\bin\Python\pkgs
         channel URLs :
          config file : C:\Program Files\ArcGIS\Pro\bin\Python\.condarc
    is foreign system : False

I can workaround this, by manually setting CONDA_ENVS_PATH to my user's home directory, but that hides the default ArcGIS Pro environment..

Is this a bug in conda itself, a bug in ArcGIS Pro's installation of conda or just wrong usage?

Best Regards


Tags (2)
5 Replies
MVP Esteemed Contributor

I can confirm the same behavior on a new, default ArcGIS Pro 1.4.1 installation.

I think this is likely both a conda and Esri issue.  Esri is still packaging conda 4.0.11 with ArcGIS Pro.  It appears Esri isn't really updating conda with the new versions of Pro.  I suspect we will get a new version of conda with ArcGIS Pro, but that is still a few months out.

The reason I mention the version of conda is that there have been many fixes with the activate script since 4.0.11.  Although I can't confirm any of those fixes addressed the issue, I suspect that one of them does.

0 Kudos
by Anonymous User
Not applicable

Jens, since you installed Pro in C:\Program Files but ran conda create without admin privilege, it had created the new environment in your local user profile. Hence when you tried to activate, conda looked for it in typical envs folder under c:\Program Files... and could not find it.

In this case, to activate your new env, first cd into the local user profile conda directory, then run the activate command by calling activate.bat with fully qualified path, as shown below:

c:\users\username\.conda\envs>"C:\Program Files\ArcGIS\Pro\bin\python\scripts\activate.bat" your_new_env_name

After this, you can change directory to your working directory and start Jupyter notebooks and this environment would continue to remain your active environment.

0 Kudos
MVP Esteemed Contributor

Atma Mani‌, although what you describe works, I still would argue that the conda bundled with ArcGIS Pro is not working "properly."  The user shouldn't have to change to his/her local env to activate that environment.

As a simple test, I downloaded and installed the latest version of miniconda, which includes conda 4.3.11.  After installing miniconda, I was able to both see and activate the environment that I created with ArcGIS Pro conda.  I used the same command that doesn't work with ArcGIS Pro conda.  I installed miniconda as administrator but ran the command as a non-privileged user, just like with my ArcGIS Pro installation.

I believe updating the version of conda will address the issue, but it may be something else with how Esri has packaged it.

by Anonymous User
Not applicable

Thanks Joshua Bixby I have conveyed your findings to the Pro team so they can consider it for our next release

0 Kudos
Occasional Contributor

Thanks Joshua and Atma for your findings and explanations!

I have a much nicer workaround for now and looking for future conda-bundles 🙂

0 Kudos