Hello everyone,
I am having an issue in setting up a Python environment to run MATLAB and ArcGIS Pro together. I have cloned the Python environment from ArcGIS and installed MATLAB Engine API within the cloned conda environment. I am unable to import ArcGIS python libraries (such as arcpy, arcgisscripting) after importing matlab.engine and vice versa as well. However, I am able to import matlab.engine or ArcGIS libraries separately. Below are the errors that I receive when I import these libraries
1. Importing matlab.engine after arcpy –
>>> import arcpy
>>> import matlab.engine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\kjain1\AppData\Local\ESRI\conda\envs\arcgispro-py3-ALOFT\lib\site-packages\matlab\engine\__init__.py", line 77, in <module>
raise EnvironmentError(secondExceptionMessage)
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance:
First issue: DLL load failed while importing matlabengineforpython3_9: The specified procedure could not be found.
Second issue: DLL load failed while importing matlabengineforpython3_9: The specified procedure could not be found.
2. Importing arcpy after matlab.engine –
>>> import matlab.engine
>>> 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\kjain1\AppData\Local\ESRI\conda\envs\arcgispro-py3-ALOFT\lib\site-packages\arcgisscripting\__init__.py", line 131, in <module>
from ._arcgisscripting import *
ImportError: DLL load failed while importing _arcgisscripting: The specified procedure could not be found.
I have installed ArcGIS Pro 3.0.2, MATLAB R2022B and the Python version is 3.9.13.
How do I resolve this DLL error?
Thanks
Were you ever able to solve this?
I'm running into the same issue, working on a script that I need to be able to launch as a tool within ArcGIS Pro, that then calls a Matlab script, which I unfortunately can't convert over to Python.
Oddly, if I just run my Python script from the command line, it works as expected, so it seems like it must be related to a DLL that ArcGIS Pro loads that conflicts with one that the Matlab engine wants.