DLL load failed for gurobipy (Windows, calling python script from Matlab)
AnsweredHi
When I am trying to run this code ‘system('D:\anaconda\python.exe dualSP.py')’ in Matlab, the following error occurs. (P.S. Note that dualSP.py runs perfectly in Pycharm.)
>> system('D:\anaconda\python.exe dualSP.py')
Traceback (most recent call last):
File "dualSP.py", line 4, in <module>
from gurobipy import *
File "D:\anaconda\lib\site-packages\gurobipy\__init__.py", line 1, in <module>
from .gurobipy import *
ImportError: DLL load failed: 找不到指定的模块。
To solve this problem, i have done the first solution introduced by Sonja. However, there is still the same error.
Best
Canqi
-
Hi Canqi,
Are you able to execute the command
> D:\anaconda\python.exe dualSP.py
from a terminal window without errors? If yes, then it looks like the path to the Gurobi \(\texttt{dll}\) is not set properly for MATLAB. You could try copying the dll to the current working directory of your MATLAB project.
Best regards,
Jaromił0 -
To make it short, it means that you lacked some "dependencies" for the libraries you wanted to use. This is a common problem when installing python packages, mainly in windows. Before trying to use any kind of library, first it is suggested to look up whether it needs another library in python "family".
The solution is to provide the python interpreter with the path-to-your-module/library. The simplest solution is to append that python path to your sys.path list. In your notebook, first try:
import sys
sys.path.append('my/path/to/module/folder')This isn't a permanent change in sys.path, because when you log out, your environment is reset, so any variables you may have set are lost.
The better (and more permanent) way to solve this is to set your PYTHONPATH, which provides the interpreter with additional directories look in for python packages/modules.
from BASH type: export PYTHONPATH=/path/to/new/folder:/another/path/...../ #each path must be separated by a colon
0 -
I have an issue when installing the gurobipy 11.0.2 version on Windows.
I keep getting the error message:
ImportError: DLL load failed while importing gurobipy: The specified procedure could not be found.
I have followed the procedure on your Gurobi's website: https://support.gurobi.com/hc/en-us/articles/360044290292-How-do-I-install-Gurobi-for-Python
Can you help fix this?
I had never such issues in the last with the previous versions.0 -
Hi Gana,
Usually this can be fixed by creating a fresh virtual environment, activating it, then running
pip install gurobipy==11.0.2
- Riley
0
Please sign in to leave a comment.
Comments
4 comments