New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APPSI: 'Could not import gurobipy' #2316
Comments
I am 95% certain that you are missing the compiled extension that APPSI relies on. This is distributed through the wheels starting in Pyomo 6.3.0. Before that (and on platforms where wheels aren't available), you should either run:
or
I am working with @michaelbynum to improve the error message for future users. |
Just to be certain, can you please post the output of:
|
Hi @michaelbynum , |
Thanks. @jsiirola is correct. What platform are you on? |
Hi @jsiirola, I tried to run the given instructions ( Stay tuned to your comments, |
I'm using miniconda, in Windows. |
pybind11 is required to compile those extensions. You should be able to install it with |
Thanks. @erikfilias, did you install pyomo with Conda or pip? |
With |
Hmm... It is strange that you did not get the precompiled libraries. Just to confirm - there were no errors when you compiled the extension? Do you get the same result from |
@michaelbynum , I was checking the building process, and noted the following: What can I do, now? Please let me know. |
Can you share the entire output? |
Sorry, I mean the output from |
(base) PS C:\WINDOWS\system32> pyomo build-extensions **** Building AMPL External function demo library **** **** Building APPSI **** **** Building PyNumero libraries **** |
That looks like an issue with your MSVC environment. The solution here: https://stackoverflow.com/questions/43858836/python-installing-clarifai-vs14-0-link-exe-failed-with-exit-status-1158 may help. |
Are you using the 32-bit or 64-bit version of Miniconda? |
The 64-bit version. |
I tried to follow the recommended steps, but I haven't found the path I'm on Windows 11; maybe it is a little different, I'll try to look at how to solve it, but I believe that should have a simple way. |
Can you reinstall pyomo and post the output? Something like
I'm trying to figure out why you didn't get the precompiled libraries. |
(base) PS C:\WINDOWS\system32> pip uninstall pyomo |
I was looking at the wheels. It looks like the library is there, but doesn't load. It might be that you are missing the MSVC redistributable runtime (https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170). Installing that package might help. If that works, then we can look at trying to bundle the necessary libraries in the Windows wheels. |
I installed the MSVC redistributable (architecture x64) as recommended to me, from https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170. |
The redistributable library might make the default build work. Can you try import pyomo.contrib.appsi.cmodel.appsi_cmodel |
This might get resolved with a Conda installation of pyomo. However, I don't think we are distributing the precompiled libraries through Conda yet. While we are figuring this out, you should be able to use a callback with the non-appsi persistent interface to Gurobi: |
@erikfilias Can you try one more thing? Can you try installing Pyomo with Python 3.8? |
@erikfilias - I was able to get the import working correctly using the following steps (I'm on Windows 10, so paths might be different on Windows 11):
^ This path might be different for you, as with the Windows Kit number. I found my Windows Kit number by navigating to Then I was able to run |
I think we have the Conda distribution working now too. You could try |
Confirmed, @michaelbynum - the distribution from conda on Windows is working. |
Thanks, @mrmundt. |
@mrmundt , I've just uninstalled miniconda and installed the last version. Following your steps, I haven't had any issues: However, I got the same error when I run I look forward to any comments or next steps. |
When you say you got the same error, do you mean the |
The instructions I provided, just to be clear, were not meant to address the I will note, we don't build for |
That's a known issue with the 6.3.0 release wheels / conda packages (see #2317). The |
Thank you, I will look forward to any update. |
I should have mentioned, if you are really intent on using pynumero right now, there are three workarounds:
|
Hi @jsiirola, I update Pyomo to 6.4.0, gurobi, and gurobipy to 9.5.1. And, tested the example in: https://pyomo.readthedocs.io/en/stable/library_reference/appsi/appsi.solvers.gurobi.html
Additionally, I tried with the other example with Ipopt in: https://pyomo.readthedocs.io/en/stable/library_reference/appsi/appsi.base.html
And again, I also got the same error: Is there something that I'm doing wrong? |
Unfortunately, we ran into difficulties distributing the precompiled libraries for Windows, and we do not have the time to track down the problem. For the foreseeable future, Windows users will have to compile the Appsi extensions locally. I apologize. I am working on removing the need for the compiled extension for the Appsi interface to Gurobi. That interface should be pure Python. Hopefully that will be ready for the next release. |
Hello all, I found the cause of failure to load compiled extension under windows: |
@zinetullinruslan Nice find! Thank you so much for digging into this. I'll get this into a PR soon. |
Dear all,
I tried to use APPSI and Gurobi as solver but I got this error: 'Could not import gurobipy'
By running the example:
I have the packages:
And:
-Gurobi 9.5.1 with its respective license.
Please, let me know if I made something wrong.
Best regards,
Erik
The text was updated successfully, but these errors were encountered: