- Launch Anaconda Prompt or Anaconda Powershell Prompt
- Type matlab at the prompt. Matlab will launch with extra environment variables configured by Anaconda's startup.
- Test in MATLAB.
Unable to import arcpy into MATLAB
7 views (last 30 days)
Show older comments
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 in Python works fine while I´m unable to import it into MATLAB. The import error seems to be more arcpy related.
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>.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1671296/image.png)
Will be grateful for any help!
*UPDATE*
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 Comments
Answers (1)
Karanjot
on 22 Apr 2024
Edited: Karanjot
on 22 Apr 2024
Hey Filip,
Kindly share details about your python installation, and also confirm if you are using the Anaconda distribution for python. The above error is common with Anaconda distribution.
This is because Anaconda maps the DLLs in a non-standard spot and adds them to the path when you start Anaconda's Prompts or Navigators. The math library uses python directly. To be fast, libraries uses compiled C-code, hence those extra DLLs.
In case you are using Anaconda, Here's a workaround:
Otherwise, If you are using any Python version > 3.8 with Windows, DLLs are only loaded from trusted locations as suggested in Python documentation: https://docs.python.org/3/whatsnew/3.8.html#ctypes
This can be fixed by adding the dll path in python using:
os.add_dll_directory("PATH_TO_DLL")
In case you still encounter the error, I recommend going through below documentation to ensure that your system is configured correctly:
I hope this helps!
0 Comments
See Also
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!