[GIS] Recreating Anaconda environment after ArcGIS Pro installation

anacondaarcgis-proarcpyinstallation

I have had to reinstall ArcGIS Pro 2.0 and have attempted to recreate an Anaconda environment, but am running into some problems. When I create a new environment from the initial ArcGIS Pro environment, I can install packages using pip, but then when I try to load them from within the cloned environment, the modules can't be found. Here are the steps I performed.

  1. Open Command Prompt as provided by ArcGIS Pro (not in the GUI)
  2. conda create --clone old --name new
  3. activate new
  4. pip install package
  5. python -c "import package"

This results in an error message. Within the new environment, sys.executable returns the old environment. If I provide the hard path the python executable in the new environment, I can load the package. But this behavior doesn't seem right. I am assuming that when I try to open python within an Anaconda environment it should use the environment's python version.

Best Answer

You may just want to move up to later version of ArcGIS Pro.

Your expectation matches the 2.2 behavior nicely.

2.2 session below (sanitized for noise).

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>conda create --clone arcgispro-py3 --name new
Source:      C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
Destination: C:\Users\user\AppData\Local\ESRI\conda\envs\new
Packages: 98
Files: 23
- Validating: ok

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>activate new

(new) C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>pip install bs4
Collecting bs4
Collecting beautifulsoup4 (from bs4)
  Using cached https://files.pythonhosted.org/packages/fe/62/720094d06cb5a92cd4b3aa3a7c678c0bb157526a95c4025d15316d594c4b/beautifulsoup4-4.6.1-py3-none-any.whl
Installing collected packages: beautifulsoup4, bs4
Successfully installed beautifulsoup4-4.6.1 bs4-0.0.1
You are using pip version 9.0.3, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

(new) C:\Program Files\ArcGIS\Pro\bin\Python\Scripts>python -c "import bs4;print(bs4.__version__)"
4.6.1
Related Question