1

I'm trying to set up PyCharm to work with the Python environment (Python 3.9.13) installed with ArcGIS Pro 3.0 on a new computer (Win 11). I've tried cloning the environment both from within ArcGIS and from the Anaconda prompt. I've activated the clone in ArcGIS, and it works as it should in there. However, when I try to use the environment in PyCharm (or elsewhere outside of ArcGIS), I can´t import the arcpy module.

C:\Users\EmanuelVogel\anaconda3\envs\Pro_ENV\python.exe C:/GIS/PyCharm_Projects/test.py
Traceback (most recent call last):
  File "C:\GIS\PyCharm_Projects\test.py", line 1, in <module>
    import arcpy as ap
  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\EmanuelVogel\anaconda3\envs\Pro_ENV\lib\site-packages\arcgisscripting\__init__.py", line 131, in <module>
    from ._arcgisscripting import *
ImportError: DLL load failed while importing _arcgisscripting: Det går inte att hitta den angivna modulen.

Process finished with exit code 1

I can import and work with other modules such as numpy. What could be the reason for this? I´ve already checked Importing ArcPy installed with ArcGIS Pro in PyCharm but can´t really make sense of it.

2
  • I have a brand new computer and didn´t set up PyCharm for arcpy before I upgraded to ArcPro 3. On my previous computer I had no trouble doing it though. Maybe I should try upgrading to version 3 on the old one and see if I get the same problem there. What I also find weird is that PyCharm lists the arcpy module when I open the environment settings.
    – Emanuelv
    Jul 1, 2022 at 9:10
  • 2
    Your title is a bit misleading. It's not a "sudden" change, but new software on a new computer. This critical detail should be present in the body of the Question and reflected in the title.
    – Vince
    Jul 1, 2022 at 13:47

4 Answers 4

1

As @Nono suggests it sounds like you do not have Pycharm configured to point to the Python interpreter that comes with ArcGIS Pro. See the link above or this link: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#add-existing-interpreter on setting the interpreter. Edit your post to include the path to Python.exe.

A simple test would be to open Pycharm, go to a Python Shell and run these commands

import sys
print(sys.executable)

This should return c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe if Pycharm is configured correctly to work with the default installation location of arcpy.

1
  • I had the cloned python.exe in C:\Users\EmanuelVogel\anaconda3\envs\Pro_ENV\python.exe as seen in the error message above. PyCharm also listed arcpy under installed modules in the active environment, so I'm pretty sure the issue was something else. I tried recloning the env but couldn´t get it to work. However, I solved this issue by reinstalling ArcGIS Pro and cloning a new environment.
    – Emanuelv
    Aug 15, 2022 at 13:46
1

I was having the exact same problem as you on my organization's ArcGIS Pro environment. I was even getting the same errors as you after cloning the python environment and trying to access arcpy on the cloned and default environment through Anaconda's Spyder IDE. I tried to access online resources that allegedly solved the issue, including here for the issue in 3.0 environments and here and here for 2.X environments. All of them didn't seem to solve the issue.

I also tried to bring this issue up with my GIS IT team who gave the following insight "ArcGIS Pro 3.0 runs on a different framework, .NET 6"; unfortunately, there seem to be a lot of changes that will need to be made to switch my organization to be .NET 6 compatible. So there might be compatibility issues with your current setup and ArcGIS Pro 3.X.

I recommend switching to ArcGIS Pro 2.9.X, as that version seems to work under many user/organizational infrastructures.

1

arcgisscripting needs to import "_arcgisscripting.pyd" (where .pyd files are just a form of DLL file). This is the cause of your error ImportError: DLL load failed while importing _arcgisscripting

Having the sys.path set so that the interpreter can find arcgisscripting doesn't seem to be sufficient for the dll loading, hence the python is imported but the dll load fails.

I was able to get it to work by adding the location of _arcgisscripting.pyd to my PYTHONPATH environment variable (on Windows: Start -> Edit the system environment variables). On ArcPro this path is C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgisscripting

1

I've encountered the same issue and tried many solutions over the internet. Now I just figured it out. ArcGIS Pro has a package manager that manages virtual enviroments. There is a default environment called :

arcgispro-py3

I cloned this environment so I can add more packages (the default env is non-modifiable). Link to the cloning guide: https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/clone-an-environment.htm

Originally my project was under C:\project-dir. I figured that it could make some issues because the whole thing can't find dll's. So I put my project under:

C:\Users\user_name\PycharmProjects\project_dir

Now things seem to work. I can successfully import arcpy now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.