pyomo icon indicating copy to clipboard operation
pyomo copied to clipboard

"Solver <class 'pyomo.contrib.appsi.base.SolverFactoryClass.register.<locals>.decorator.<locals>.LegacySolver'> is not available (NeedsCompiledExtension)" when attempting to call `appsi_ipopt`

Open makansij opened this issue 3 years ago • 3 comments

Summary

I cannot get appsi_ipopt to be recognized by pyomo. Although it recognizes ipopt, and I have Here's what I did to install appsi_ipopt

  • I ranpython build.py per the instructions at the bottom of this page.

Here's what I did to install ipopt:

  • I followed the directions here, and also compiled/installed HSL/MA27. IPOPT seems to be running fine, and when I replace appsi_ipopt with ipopt in the code excerpt below, it runs perfectly fine.

Steps to reproduce the issue

import pyomo.environ as pyo
import pyomo.contrib.pyros as pyros
ipopt_solver = pyo.SolverFactory('appsi_ipopt')
ipopt_solver.available()

Error Message

---------------------------------------------------------------------------
ApplicationError                          Traceback (most recent call last)
Input In [4], in <cell line: 4>()
      2 import pyomo.contrib.pyros as pyros
      3 ipopt_solver = pyo.SolverFactory('appsi_ipopt')
----> 4 ipopt_solver.available()

File ~/opt/anaconda3/lib/python3.9/site-packages/pyomo/contrib/appsi/base.py:1306, in LegacySolverInterface.available(self, exception_flag)
   1304 ans = super(LegacySolverInterface, self).available()
   1305 if exception_flag and not ans:
-> 1306     raise ApplicationError(f'Solver {self.__class__} is not available ({ans}).')
   1307 return bool(ans)

ApplicationError: Solver <class 'pyomo.contrib.appsi.base.SolverFactoryClass.register.<locals>.decorator.<locals>.LegacySolver'> is not available (NeedsCompiledExtension).

For what it's worth, the following prints True:

ipopt_solver = pyo.SolverFactory('ipopt')
ipopt_solver.available()

Information on your system

Pyomo version: 6.4.1 Python version: 3.9 Operating system: MacOS Monterey Solver (if applicable): APPSI_IPOPT

Is it possible to tell appsi_ipopt where to find the ipopt files that were installed previously? If not, then what is the message referring to when it says NeedsCompiledExtension, if IPOPT is already compiled/installed and functional?

makansij avatar Sep 10 '22 04:09 makansij

The easiest way to debug this is to find the shared library that was built when running python build.py. By default this should go somewhere like ~/.pyomo/lib/python3.9/site-packages/appsi_cmodel.cpython-39-<system>.so. If you can find that shared library, cd into that directory, and then try to import appsi_cmodel from a python session or script. You should get a more informative error message that way.

michaelbynum avatar Sep 12 '22 14:09 michaelbynum

Thanks @michaelbynum. While in ~/.pyomo/lib/python3.9/site-packages I ran a python session, and import appsi_cmodel works with no trouble. I don't imagine this tells us much since it doesn't fail. I also tried adding this to path just by doing sys.path.append('~/.pyomo/lib/python3.9/site-packages') but that didn't change anything.

What else can I do to trigger something more informative?

makansij avatar Sep 17 '22 01:09 makansij

@makansij, try removing the try-except statement in pyomo/contrib/appsi/cmodel/init.py in the _importer() function.

michaelbynum avatar Sep 17 '22 03:09 michaelbynum

Sorry - I must've missed this post before - trying this now, thanks!

makansij avatar Oct 02 '22 22:10 makansij

@makansij, try removing the try-except statement in pyomo/contrib/appsi/cmodel/init.py in the _importer() function.

I removed the try, except block, and unindented the finally block to no avail. Still gives

ApplicationError: Solver <class 'pyomo.contrib.appsi.base.SolverFactoryClass.register.<locals>.decorator.<locals>.LegacySolver'> is not available (NeedsCompiledExtension).

The directions for installing it seem pretty straightforward, but is it possible I missed something there? Or perhaps another issue with the interface with ipopt doesn't work, even though ipopt does?

makansij avatar Oct 03 '22 18:10 makansij

@makansij, do you by chance have another file or directory somewhere in your sys.path that is called appsi_cmodel*? Perhaps a test file, directory, or an old build of appsi?

jsiirola avatar Oct 07 '22 14:10 jsiirola

@makansij is this still an issue for you or can this be closed?

blnicho avatar Nov 03 '22 22:11 blnicho

Closing this issue due to lack of response. If you are still experiencing this issue, feel free to reopen or open a new issue.

mrmundt avatar Jan 04 '24 17:01 mrmundt