Unable to import arcpy into MATLAB

04-17-2024 02:09 AM
New Contributor III
Using MATLAB 2023b, trying to run Python commands, mainly ArcGIS Pro related stuff via arcpy library. pyenv is set to use the correct Python installation (the one containing arcpy).
Arcpy works fine on my computer. Also tried restarting both the computer and ArcGIS Pro. Even reinstalled ArcGIS Pro. Made an arcpy clone, unsuccessfully tried to update all packages it contains (via Package manager in ArcGIS Pro options menu). I get the same problem for both original arcpy and the clone.
It crashes while importing it. This is weird because I can import and use math library, which is installed in the Python intepreter by default. I use "a = py.importlib.import_module('arcpy');" to import it.
The error I get:
Python Error: ImportError: DLL load failed while importing _arcgisscripting: <'listed procedure not found' - kind of message in my system´s language>.


Arcpy in Python works fine while I´m unable to import it into MATLAB. Posting the question here because it´s related to Python/arcPY. Asked the same question in MATLAB forum, got no answer yet. Think it makes more sense to ask it here because everything related to my MATLAB installation and Python compatibility seems fine. The import error seems to be more arcpy related.
Will be grateful for any help!
1) Adding arcpy-Python interpreter into PATH as suggested here didn´t help.
2) Tested importing arcpy into MATLAB on different PC, setting pyenv to arcpy interpreter worked, so did working with other libraries installed in it (e. g. math, mentioned in 2st paragraph). Got exactly the same error.
0 Kudos
0 Replies