Closed KanaBaradei closed 10 hours ago
Looking at the files I found: and: I'm not a programmer and my knowledge is very limited so I don't know why it can't find the solver on the .exe but it can on the VSC. Any help is greatly appreciated.
This is not related to linopy
, might be an issue with pyinstaller
or is simply wrong usage.
Some things to keep in mind:
pip install linopy
. You need to install it in addition to linopy (pip install gurobipy
or for all solvers pip install 'linopy[solvers]'
). Please check if you do this in your exe workflow.linopy
is loaded before gurobipy
is installed. Linopy does the check for available solvers upon loading, so any installations after that will not be found.Without more information about your script and the pyinstaller
command, this cannot be debugged.
Gurobipy is installed. I'm running the script in VSC and everything works, however when I run that same .exe on this exact same machine it throws the error shown above. The linopy part of the script is very basic, I construct a model and then solve it. The commands sent to pyinstaller are: pyinstaller --noconfirm --onefile --console "path to the file". I already had this same thing working with pyomo and the executable worked. Maybe there is a problem in paths or something?
Problem solved, for anyone that has this issue in the future: I downloaded one of the examples of GUROBI directly from their website, ran it on Visual Studio Code, verified that it worked. Created the .exe and found that one module was missing, added it to hidden options in pyinstaller and then another one popped. After 3 iterations adding the missing modules each time it finally worked. After that I went back to my linopy script and added those modules and it finally worked.
This are the modules: --hidden-import "gurobipy._util" --hidden-import "gurobipy._attrutil" --hidden-import "gurobipy._modelutil" Hope this helps anyone in the future.
@lkstrp thank you for your time. It was indeed a problem with pyinstaller and gurobi.
Great, that you could resolve this!
Dear all,
I can run my script without problems using Visual Studio Code, however when I create the .exe using autopytoexe the following error appears on the console:
I was using pyomo on the past and it worked both on VSC and the .exe. I'm wondering if it is a problem with linopy not being able to call gurobi correctly in this situation?