Failed to "import gurobipy" even after running setup.py or pysetup.bat
After typing "import gurobipy", this would show up:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\1\AppData\Local\Programs\Python\Python38\lib\site-packages\gurobipy\__init__.py", line 1, in <module>
from .gurobipy import *
ImportError: DLL load failed while importing gurobipy: 找不到指定的模块。(EN:The specified module could not be found)
I've tried uninstalling and reinstalling python and gurobi, and made sure both are the 64 bits version.
-
How did you install Gurobi? Could you please share the commands you used and the resulting output?
Cheers,
Matthias0 -
I first run the .msi file, keeping every setting as default. Then, from the installation path, I ran python setup.py install, which returns:
running install
running build
running build_py
creating build
creating build\lib
creating build\lib\gurobipy
copying python38\lib\gurobipy\__init__.py -> build\lib\gurobipy
copying python38\lib\gurobipy\gurobipy.pyd -> build\lib\gurobipy
running install_lib
byte-compiling C:\Users\1\AppData\Local\Programs\Python\Python38\Lib\site-packages\gurobipy\__init__.py to __init__.cpython-38.pyc
running install_egg_info
Removing C:\Users\1\AppData\Local\Programs\Python\Python38\Lib\site-packages\gurobipy-9.0.1-py3.8.egg-info
Writing C:\Users\1\AppData\Local\Programs\Python\Python38\Lib\site-packages\gurobipy-9.0.1-py3.8.egg-info
removing C:\gurobi901\win64\build0 -
Could you please try using the Anaconda Python 3.8 distribution? This works fine with Gurobi. Apparently, there is some issue with the "official" Python 3.8 and Gurobi.
Cheers,
Matthias0 -
I downgraded python to 3.7.5 and it works too. Thanks.
0 -
I have installed gurobi 902 and python 3.8.3.
I had earlier used gurobi 811 and python 2.7.
In both the above cases I uesd to get the DLL error.
Solution:
1. Open Anaconda promt as administrator
2. go to gurobi/win directory, for example, cd gurobi902/win64
3. type python setup.py install
and you are free to use gurobi any where in your system.
The only problem with this solution is you have to do it evrytime you start your system.
0
Please sign in to leave a comment.
Comments
5 comments