Select to view content in your preferred language

arcpy import error in cloned env

5264
14
Jump to solution
08-09-2022 11:20 AM
PhilipWhite1
New Contributor III

Hello,

I'm working on setting up an environment that can work with Spyder 5 and ArcGIS Pro. I'm on a fresh installation of 3.0. I have cloned the default environment in the new Package Manager, and it is named arcgispro-spy5. I created this clone so I can install Spyder in the cloned environment. When I attempt to import arcpy, I get this error:

 

 

(arcgispro-spy5) C:\Users\phwh9568\AppData\Local\ESRI\conda\envs\arcgispro-spy5>python
Python 3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\__init__.py", line 77, in <module>
    from arcpy.geoprocessing import gp
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from ._base import *
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 14, in <module>
    import arcgisscripting
  File "C:\Users\phwh9568\AppData\Local\ESRI\conda\envs\arcgispro-spy5\lib\site-packages\arcgisscripting\__init__.py", line 131, in <module>
    from ._arcgisscripting import *
ImportError: DLL load failed while importing _arcgisscripting: The specified module could not be found.

 

 

I get this whether I do it in the command prompt or from Spyder. But, if I switch the environment in my command prompt back to the default arcgispro-py3 environment, I'm able to import arcpy just fine.

What is going on here? Does anyone have guidance on how to correct this?

Thanks,

Phil

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

Yep, conda-forge is the likely culprit, I've had similar issues before with arcgispro-py3 clones.  

conda config --remove channels conda-forge

Then re-create your clone.

When I need to create a conda env with conda-forge packages, I just set the channel on the command-line

conda create -c conda-forge -n mynewenv packages that I want

View solution in original post

14 Replies
DanPatterson
MVP Esteemed Contributor

conda-forge packages could be the problem.

I would also check to ensure that spyder isn't installed in the base/arcgis-pro3 environment.

I would uninstall spyder from whatever environment you did install it in and install it in the clone from the conda defaults channel even if it isn't (for whatever reason) the latest.

If you want to install it in the arcgis pro environment and not a clone, do what I do

>>> conda install spyder --no-pin

 


... sort of retired...
ShaunWalbridge
Esri Regular Contributor

Can you share the output of  `conda list` on the environment? This is the kind of error that is typical when the installed ArcPy build differs from what is present in the environment, but other things can also cause it depending on the contents of the environment. As Dan mentions, conda-forge packages can be an issue as they do not share a common ABI with the defaults and Esri packages, and for example the Python interpreter used is from conda-forge.

0 Kudos
PhilipWhite1
New Contributor III

Hello Shaun,

Sure:

(arcgispro-spy5) C:\Users\phwh9568\AppData\Local\ESRI\conda\envs\arcgispro-spy5>conda list
# packages in environment at C:\Users\phwh9568\AppData\Local\ESRI\conda\envs\arcgispro-spy5:
#
# Name                    Version                   Build  Channel
alabaster                 0.7.12                     py_0    conda-forge
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
arcgis                    2.0.1                 py39_2825    esri
arcgispro                 3.0                           0    esri
arcpy                     3.0             py39_arcgispro_36045  [arcgispro]  esri
arrow                     1.2.2              pyhd8ed1ab_0    conda-forge
arrow-cpp                 1.0.1                        10    esri
asn1crypto                1.5.1              pyhd8ed1ab_0    conda-forge
astroid                   2.5.3            py39hcbf5309_0    conda-forge
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
atomicwrites              1.4.1              pyhd8ed1ab_0    conda-forge
attrs                     22.1.0             pyh71513ae_1    conda-forge
autopep8                  1.6.0              pyhd8ed1ab_0    conda-forge
azure-core                1.12.0                     py_0    esri
azure-storage-blob        12.8.0                     py_0    esri
babel                     2.10.3             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
bcrypt                    3.2.2            py39hb82d6ee_0    conda-forge
binaryornot               0.4.4                      py_1    conda-forge
black                     22.6.0           py39hcbf5309_2    conda-forge
blas                      1.0                         mkl
bleach                    5.0.1              pyhd8ed1ab_0    conda-forge
blinker                   1.4              py39haa95532_0
bottleneck                1.3.4            py39h080aedc_0
brotlipy                  0.7.0           py39hb82d6ee_1004    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2022.6.15            h5b45459_0    conda-forge
cached-property           1.5.2                      py_0
cachetools                4.2.2              pyhd3eb1b0_0
certifi                   2022.6.15        py39hcbf5309_0    conda-forge
cffi                      1.15.1           py39h0878f49_0    conda-forge
cftime                    1.5.0                    py39_1    esri
chardet                   5.0.0            py39hcbf5309_0    conda-forge
charset-normalizer        2.1.0              pyhd8ed1ab_0    conda-forge
click                     8.1.3            py39hcbf5309_0    conda-forge
cloudpickle               2.1.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.5              pyhd8ed1ab_0    conda-forge
cookiecutter              2.1.1              pyh6c4a22f_0    conda-forge
cppzmq                    4.4.1                         4    esri
cryptography              37.0.4           py39h7bc7c5c_0    conda-forge
cycler                    0.11.0             pyhd3eb1b0_0
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
despatch                  0.2.0                    py39_0    esri
diff-match-patch          20200713           pyh9f0ad1d_0    conda-forge
docutils                  0.19             py39hcbf5309_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
et_xmlfile                1.1.0            py39haa95532_0
executing                 0.9.1              pyhd8ed1ab_0    conda-forge
fastcache                 1.1.0            py39h196d8e1_0
flake8                    3.9.2              pyhd8ed1ab_0    conda-forge
freetype                  2.12.1                        0    esri
future                    0.18.2           py39hcbf5309_5    conda-forge
gdal                      3.4.0           arcgispro_py39_17119  [arcgispro]  esri
geomet                    0.3.0                      py_1    esri
h5py                      3.6.0                    py39_4    esri
html5lib                  1.1                pyh9f0ad1d_0    conda-forge
icc_rt                    2019.0.5            arcgispro_0  [arcgispro]  esri
icu                       69.1                 h0e60522_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
imagesize                 1.4.1              pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.4           py39hcbf5309_0    conda-forge
importlib_metadata        4.11.4               hd8ed1ab_0    conda-forge
importlib_resources       5.9.0              pyhd8ed1ab_0    conda-forge
inflection                0.5.1              pyh9f0ad1d_0    conda-forge
iniconfig                 1.1.1              pyhd3eb1b0_0
intel-openmp              2020.0            arcgispro_166  [arcgispro]  esri
intervaltree              3.0.2                      py_0    conda-forge
ipykernel                 5.5.5            py39h832f523_0    conda-forge
ipython                   8.4.0            py39hcbf5309_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.6.5                      py_0    esri
isodate                   0.6.0                      py_0    esri
isort                     5.10.1             pyhd8ed1ab_0    conda-forge
jdcal                     1.4.1              pyhd3eb1b0_0
jedi                      0.18.1             pyhd8ed1ab_2    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
jinja2-time               0.2.0              pyhd8ed1ab_3    conda-forge
jpeg                      9e                   h8ffe710_2    conda-forge
json5                     0.9.5                      py_0    esri
jsonschema                4.9.1              pyhd8ed1ab_0    conda-forge
jupyter_client            6.1.12             pyhd8ed1ab_0    conda-forge
jupyter_console           6.4.0                      py_1    esri
jupyter_contrib_core      0.3.3                      py_4    esri
jupyter_contrib_nbextensions 0.5.1                     py_24    esri
jupyter_core              4.11.1           py39hcbf5309_0    conda-forge
jupyter_highlight_selected_word 0.2.0                      py_4    esri
jupyter_latex_envs        1.4.6                      py_3    esri
jupyter_nbextensions_configurator 0.4.1                      py_3    esri
jupyterlab                2.2.10                     py_0    esri
jupyterlab_server         1.2.0                      py_0
jupyterlab_widgets        1.0.0              pyhd3eb1b0_1
keyring                   23.8.2           py39hcbf5309_0    conda-forge
kiwisolver                1.3.2            py39hd77b12b_0
lazy-object-proxy         1.7.1            py39hb82d6ee_1    conda-forge
lerc                      3.0                pyh39e3cac_0    esri
libclang                  13.0.1          default_h81446c8_0    conda-forge
libdeflate                1.8                  h2bbff1b_5
libffi                    3.4.2                h8ffe710_5    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
libpng                    1.6.37               h1d00b33_3    conda-forge
libprotobuf               3.19.1               h23ce68f_0
libsodium                 1.0.18               h8d14728_1    conda-forge
libspatialindex           1.9.3                h39d44d4_4    conda-forge
libtiff                   4.3.0                         1    esri
libxml2                   2.9.14               hf5bbc77_3    conda-forge
libxslt                   1.1.35               h34f844d_0    conda-forge
libzlib                   1.2.12               h8ffe710_2    conda-forge
lxml                      4.9.1            py39hb82d6ee_0    conda-forge
lz4-c                     1.9.3                h2bbff1b_1
markupsafe                2.1.1            py39hb82d6ee_1    conda-forge
matplotlib                3.4.3           py39_arcgispro_4  [arcgispro]  esri
matplotlib-base           3.4.3           py39_arcgispro_4  [arcgispro]  esri
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mccabe                    0.6.1                      py_1    conda-forge
mistune                   0.8.4           py39hb82d6ee_1005    conda-forge
mkl                       2020.0            arcgispro_167  [arcgispro]  esri
mkl-service               2.3.0                    py39_2    esri
mkl_fft                   1.3.0                    py39_0    esri
mkl_random                1.2.2                    py39_0    esri
mpmath                    1.2.1            py39haa95532_0
msrest                    0.6.21                     py_0    esri
mypy_extensions           0.4.3            py39hcbf5309_5    conda-forge
nbconvert                 5.6.1              pyhd8ed1ab_2    conda-forge
nbformat                  5.4.0              pyhd8ed1ab_0    conda-forge
netcdf4                   1.5.7           py39_arcgispro_3  [arcgispro]  esri
networkx                  2.7.1              pyhd3eb1b0_0
nlohmann_json             3.7.0                         2    esri
nose                      1.3.7           pyhd3eb1b0_1008
notebook                  5.7.10                   py39_1    esri
ntlm-auth                 1.4.0                      py_0    esri
numexpr                   2.8.1                    py39_0    esri
numpy                     1.20.1                   py39_0    esri
numpy-base                1.20.1                   py39_0    esri
numpydoc                  1.4.0              pyhd8ed1ab_1    conda-forge
oauthlib                  3.2.0                    py39_0    esri
olefile                   0.46               pyhd3eb1b0_0
openpyxl                  3.0.9              pyhd3eb1b0_0
openssl                   1.1.1q               h8ffe710_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.3.5            py39h6214cd6_0
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
paramiko                  2.11.0             pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pathspec                  0.9.0              pyhd8ed1ab_0    conda-forge
pefile                    2019.4.18                  py_0
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.1.0                    py39_3    esri
pip                       22.2.2             pyhd8ed1ab_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
platformdirs              2.5.2              pyhd8ed1ab_1    conda-forge
pluggy                    0.13.1           py39hcbf5309_4    conda-forge
pro_notebook_integration  3.0                      py39_1    esri
prometheus_client         0.8.0                      py_0    esri
prompt-toolkit            3.0.30             pyha770c72_0    conda-forge
prompt_toolkit            3.0.30               hd8ed1ab_0    conda-forge
protobuf                  3.19.1           py39hd77b12b_0
psutil                    5.9.1            py39hb82d6ee_0    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
py                        1.11.0             pyh6c4a22f_0    conda-forge
pyarrow                   1.0.1                    py39_3    esri
pybind11                  2.7.1                         0    esri
pybind11_json             0.2.6                         3    esri
pycodestyle               2.7.0              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydocstyle                6.1.1              pyhd8ed1ab_0    conda-forge
pyflakes                  2.3.1              pyhd8ed1ab_0    conda-forge
pygments                  2.12.0             pyhd8ed1ab_0    conda-forge
pyjwt                     2.4.0                      py_1    esri
pylint                    2.7.2            py39hcbf5309_0    conda-forge
pyls-spyder               0.4.0              pyhd8ed1ab_0    conda-forge
pynacl                    1.5.0            py39hb3671d1_1    conda-forge
pyodbc                    4.0.32           py39hd77b12b_1
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pypdf2                    1.26.0                     py_4    esri
pyqt                      5.12.3           py39hcbf5309_8    conda-forge
pyqt-impl                 5.12.3           py39h415ef7b_8    conda-forge
pyqt5-sip                 4.19.18          py39h415ef7b_8    conda-forge
pyqtchart                 5.12             py39h415ef7b_8    conda-forge
pyqtwebengine             5.12.1           py39h415ef7b_8    conda-forge
pyrsistent                0.18.1           py39hb82d6ee_1    conda-forge
pyshp                     2.1.3              pyhd3eb1b0_0
pysocks                   1.7.1            py39hcbf5309_5    conda-forge
pytest                    6.2.4                    py39_0    esri
python                    3.9.13          h9a09f29_0_cpython    conda-forge
python-certifi-win32      1.6                        py_0    esri
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.16.1             pyhd8ed1ab_0    conda-forge
python-lsp-black          1.1.0              pyhd8ed1ab_0    conda-forge
python-lsp-jsonrpc        1.0.0              pyhd8ed1ab_0    conda-forge
python-lsp-server         1.2.4              pyhd8ed1ab_0    conda-forge
python-slugify            6.1.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      1_cp39    esri
pytoolconfig              1.2.2              pyhd8ed1ab_0    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pywin32                   303              py39hb82d6ee_0    conda-forge
pywin32-ctypes            0.2.0           py39hcbf5309_1005    conda-forge
pywin32-security          302                      py39_1    esri
pywinpty                  2.0.1                    py39_0    esri
pyyaml                    6.0              py39hb82d6ee_4    conda-forge
pyzmq                     23.2.0           py39he46f08e_0    conda-forge
qdarkstyle                3.0.2              pyhd8ed1ab_0    conda-forge
qstylizer                 0.2.1              pyhd8ed1ab_0    conda-forge
qt                        5.12.9               h556501e_6    conda-forge
qtawesome                 1.1.1              pyhd8ed1ab_0    conda-forge
qtconsole                 5.1.1              pyhd8ed1ab_0    conda-forge
qtpy                      2.1.0              pyhd8ed1ab_0    conda-forge
regex                     2022.7.25        py39hb82d6ee_0    conda-forge
requests                  2.28.1             pyhd8ed1ab_0    conda-forge
requests-kerberos         0.12.0                        0    esri
requests-negotiate-sspi   0.5.3                    py39_0    esri
requests-oauthlib         1.3.0                      py_0
requests-toolbelt         0.9.1              pyhd3eb1b0_0
requests_ntlm             1.1.0                      py_0    esri
rope                      1.3.0              pyhd8ed1ab_0    conda-forge
rtree                     1.0.0            py39h09fdee3_1    conda-forge
saspy                     3.7.8                      py_0    esri
scipy                     1.6.2                    py39_0    esri
send2trash                1.8.0              pyhd3eb1b0_1
setuptools                63.4.2           py39hcbf5309_0    conda-forge
simplegeneric             0.8.1            py39haa95532_2
six                       1.16.0             pyh6c4a22f_0    conda-forge
snowballstemmer           2.2.0              pyhd8ed1ab_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
sphinx                    5.1.1              pyhd8ed1ab_1    conda-forge
sphinxcontrib-applehelp   1.0.2                      py_0    conda-forge
sphinxcontrib-devhelp     1.0.2                      py_0    conda-forge
sphinxcontrib-htmlhelp    2.0.0              pyhd8ed1ab_0    conda-forge
sphinxcontrib-jsmath      1.0.1                      py_0    conda-forge
sphinxcontrib-qthelp      1.0.3                      py_0    conda-forge
sphinxcontrib-serializinghtml 1.1.5              pyhd8ed1ab_2    conda-forge
spyder                    5.1.5            py39hcbf5309_1    conda-forge
spyder-kernels            2.1.3            py39hcbf5309_1    conda-forge
sqlalchemy                1.3.12           py39h196d8e1_0
sqlite                    3.39.2               h8ffe710_0    conda-forge
stack_data                0.3.0              pyhd8ed1ab_0    conda-forge
swat                      1.9.3                    py39_0    esri
sympy                     1.9                      py39_1    esri
terminado                 0.13.1           py39haa95532_0
testpath                  0.6.0              pyhd8ed1ab_0    conda-forge
text-unidecode            1.3                        py_0    conda-forge
textdistance              4.3.0              pyhd8ed1ab_0    conda-forge
three-merge               0.1.1              pyh9f0ad1d_0    conda-forge
tinycss2                  1.1.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tornado                   6.2              py39hb82d6ee_0    conda-forge
traitlets                 5.3.0              pyhd8ed1ab_0    conda-forge
typed-ast                 1.5.4            py39hb82d6ee_0    conda-forge
typing-extensions         4.3.0                hd8ed1ab_0    conda-forge
typing_extensions         4.3.0              pyha770c72_0    conda-forge
tzdata                    2021e                hda174b7_0
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
ujson                     5.3.0            py39h415ef7b_0    conda-forge
unidecode                 1.3.4              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.11            pyhd8ed1ab_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
watchdog                  2.1.9            py39hcbf5309_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
widgetsnbextension        3.5.2            py39haa95532_0
win_inet_pton             1.1.0            py39hcbf5309_4    conda-forge
wincertstore              0.2             py39hcbf5309_1008    conda-forge
winkerberos               0.8.0                    py39_0    esri
winpty                    0.4.3                         4
wrapt                     1.14.1           py39hb82d6ee_0    conda-forge
x86cpu                    0.4                      py39_1    esri
xarray                    0.20.1             pyhd3eb1b0_1
xeus                      0.24.1                        8    esri
xeus-python               0.8.2                        10    esri
xlrd                      2.0.1              pyhd3eb1b0_0
xlwt                      1.3.0            py39haa95532_0
xtl                       0.6.15                        1    esri
xz                        5.2.5                h62dcd97_1    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
yapf                      0.32.0             pyhd8ed1ab_0    conda-forge
zeromq                    4.3.4                h0e60522_1    conda-forge
zipp                      3.8.1              pyhd8ed1ab_0    conda-forge
zlib                      1.2.12               h8ffe710_2    conda-forge
zlib-ng                   2.0.5                         0    esri
zstd                      1.4.9                h19a0ad4_0

I appreciate it!

-Phil

0 Kudos
PhilipWhite1
New Contributor III

And I'll point out that I installed Spyder 5.1.5. The latest version produces a laundry list of conflicts and eventually fails.

0 Kudos
DanPatterson
MVP Esteemed Contributor

I have flagged the 5.2.2 version that Anaconda recently posted, it isn't even the correct version.

>>> conda install spyder=5.1.5 --no-pin

is actually what my recent notes show so as not to get the 5.2.2 version.

You cana do a pip install of 5.3.2 if you must, but it is harder to maintain in a conda environment unless you like to tinker


... sort of retired...
0 Kudos
ShaunWalbridge
Esri Regular Contributor

OK, thanks appreciate it. Somehow this environment has almost all conda-forge packages, which I would expect to fail because of library ABI compatibility issues. If you could, I'd like to see the history file located at:

C:\Users\phwh9568\AppData\Local\ESRI\conda\envs\arcgispro-spy5\conda-meta\history

 

That should make more clear how the environment was set up to get into this state. From my end, I tried installing Spyder into a default clone and that worked, and it also seemed to work with `conda install conda-forge::spyder` so I'm guessing there is something happening with the channel priorities which is impacting how this is getting configured. It is also possible that `conda-forge` is the top priority channel in your `.condarc` file and will force packages to that channel by default.

PhilipWhite1
New Contributor III

Hi Shaun,

Oh, I really appreciate this because I'm learning something new here. Here's the content of my .condarc file: 

channels:
  - conda-forge
  - defaults
ssl_verify: true

Sounds like you're onto something? And I have to admit I've not had to tinker with this stuff before.

I attached a text file with the history meta since it's pretty long... 

Much appreciated!

Phil

0 Kudos
Luke_Pinner
MVP Regular Contributor

Yep, conda-forge is the likely culprit, I've had similar issues before with arcgispro-py3 clones.  

conda config --remove channels conda-forge

Then re-create your clone.

When I need to create a conda env with conda-forge packages, I just set the channel on the command-line

conda create -c conda-forge -n mynewenv packages that I want
PhilipWhite1
New Contributor III

Big thanks to Shaun and Luke--you all are ALRIGHT!

Removing conda-forge as my priority channel did the trick here. I didn't realize this would get in the way of ESRI environments. So, thanks Shaun, this was educational for me. 

conda config --remove channels conda-forge

 did the trick as Luke suggested.

So thanks to both of you--and thanks to Dan as well for responding to this and to so many other posts over the years.

-Phil

0 Kudos