Select to view content in your preferred language

Arcpy Conda Installation Crashed with Standalone Environment

3508
8
Jump to solution
11-10-2022 09:32 PM
ZhongyuYang
Emerging Contributor

After creating a new ArcPy environment within a standalone installation of Conda, the installation failed for some reason.

This same setup worked without any issues in the past. 

This is a bare-bones recipe for creating an ArcPy environment within Anaconda.

 

 

conda create -n ArcGIS
conda activate ArcGIS
conda install arcpy=3.0 -c esri

 

 

 

Below is the error message:

Preparing transaction: done
Verifying transaction: done
Executing transaction: | Uninstalling prior versions of arcgis widget
Installing C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\arcgis\widgets/js/dist -> arcgis
Up to date: C:\Users\yangz\.conda\envs\ArcGIS\share\jupyter\nbextensions\arcgis\arcgis-map-ipywidget.js
Up to date: C:\Users\yangz\.conda\envs\ArcGIS\share\jupyter\nbextensions\arcgis\arcgis-map-ipywidget.js.map
Up to date: C:\Users\yangz\.conda\envs\ArcGIS\share\jupyter\nbextensions\arcgis\extension.js
- Validating: ok

To initialize this nbextension in the browser every time the notebook (or other app) loads:

jupyter nbextension enable arcgis --py --sys-prefix

Enabling notebook extension arcgis/extension...
- Validating: ok

-
done
ERROR conda.core.link:_execute(730): An error occurred while installing package 'esri::jupyter_contrib_nbextensions-0.5.1-py_24'.
Rolling back transaction: done

LinkError: post-link script failed for package esri::jupyter_contrib_nbextensions-0.5.1-py_24
location of failed script: C:\Users\yangz\.conda\envs\ArcGIS\Scripts\.jupyter_contrib_nbextensions-post-link.bat
==> script messages <==
<None>
==> script output <==
stdout:
stderr: Traceback (most recent call last):
File "C:\Users\yangz\.conda\envs\ArcGIS\Scripts\jupyter-contrib-nbextension-script.py", line 5, in <module>
from jupyter_contrib_nbextensions.application import main
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\jupyter_contrib_nbextensions\application.py", line 15, in <module>
from jupyter_contrib_nbextensions.install import (
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\jupyter_contrib_nbextensions\install.py", line 12, in <module>
import latex_envs
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\latex_envs\__init__.py", line 3, in <module>
from . import latex_envs
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\latex_envs\latex_envs.py", line 20, in <module>
from nbconvert.exporters.exporter import Exporter
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\nbconvert\__init__.py", line 4, in <module>
from .exporters import *
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\nbconvert\exporters\__init__.py", line 3, in <module>
from .html import HTMLExporter
File "C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\nbconvert\exporters\html.py", line 12, in <module>
from jinja2 import contextfilter
ImportError: cannot import name 'contextfilter' from 'jinja2' (C:\Users\yangz\.conda\envs\ArcGIS\lib\site-packages\jinja2\__init__.py)

return code: 1

()

 

 

1 Solution

Accepted Solutions
eirikaa
New Contributor

The problem can be solved by installing jinja2 separately before arcpy with a downgraded version, e.g: jinja2 3.0.3 which is shipped with ArcGIS pro. 

conda install jinja2=3.0.3

Then arcpy should be ready to be installed. 

Seems like the dependency check isn't very well tested 

 

View solution in original post

Tags (3)
8 Replies
WildersonMedina
New Contributor

Hi @ZhongyuYang 

I am having the same issue. I don't know what is wrong but I guess it has to be with updates in conda.

So far I solved this by installing spyder with pip. I am also working with geopandas so I used pip to install it too. I don't know where arcpy comes in these packages but is working for me. 

I got a warning about some dependencies missing, but will be using this configuration until I figure it out.

Tags (3)
ZhongyuYang
Emerging Contributor

I still have this problem unresolved. Does anyone have the same problem?

0 Kudos
MichaelMannion
Regular Contributor

Yes, I'm having the same issue.

I've been rebuilding a conda environment that includes the arcpy module every couple of weeks for the past five months using the same `conda create` command. This started failing for the first time today, with the same error listed in your original post.

Like in your example, I can reproduce the error with a simple environment that only includes the `arcpy` module.

I can work around the error by using the Python environment included with the ArcGIS Pro installation on my Windows machine: Start > ArcGIS > Python Command Prompt

I have a variety of Python projects in-progress, some with ArcGIS and some without. Correspondingly, I'd prefer to use a common, stand-alone miniconda installation to manage everything, instead of having to open an ArcGIS-specific command prompt every time I need to run something that uses arcpy. But, alas...

I don't have time to diagnose this further at the moment, so I'm going to use the workaround for now and try again in a few weeks. Just wanted to let you know you're not alone. Thanks for starting this thread.

0 Kudos
CoMAGOL_ADMINISTRATOR
Regular Contributor

Got the same issue here

use miniconda to create a python 3.7 environment
tested all couple weeks ago were fine. 
re-test this week start failing on arcpy=2.9 installation 

conda install arcgis=2.0.0 -- passed
conda install arcpy=2.9     -- start failing last week 

Not sure whether the anaconda repo managed by ESRI or by anaconda team?
Hope this can be resolved quick or roll back to the version that was working earlier.

Regards, 

Vicky 

0 Kudos
eirikaa
New Contributor

The problem can be solved by installing jinja2 separately before arcpy with a downgraded version, e.g: jinja2 3.0.3 which is shipped with ArcGIS pro. 

conda install jinja2=3.0.3

Then arcpy should be ready to be installed. 

Seems like the dependency check isn't very well tested 

 

Tags (3)
CoMAGOL_ADMINISTRATOR
Regular Contributor

hi @eirikaa 

thanks a lot, that works for my miniconda package (target to pro-2.9). 

update jinja2 version to 3.0.3 after arcgis=2.0.0 is installed

conda install jinja2=3.0.3

Then use Conda install arcpy=2.9 without issue. 

Thanks again
Vicky 

0 Kudos
ZhongyuYang
Emerging Contributor

This one works!

0 Kudos
MichaelMannion
Regular Contributor

Thank you @eirikaa for the solution!

FWIW, I was able to include the jinja2 version in my initial environment creation command, as follows:

conda create --name hydro --channel esri python=3.9 arcpy=3.0 arcgis=2.0.1 jinja2=3.0.3

It's a trivial refinement, but saves the step of explicitly installing arcpy after creating the environment.

Note that specifying the other package versions aren't required. I have them in there for stability, but it works both ways.

Tested using conda 22.11.1 (from a miniconda single-user installation) on a machine with ArcGIS Pro 3.0.3 (I'm not sure if the Pro version matters when creating the environment, or just when using arcpy).