3

Successfully installed pyomo on databricks using the collowing command -

pip install 'pyomo[optional]'

Output - Successfully installed algopy-0.5.7 casadi-3.5.5 dill-0.3.5.1 et-xmlfile-1.1.0 mpmath-1.2.1 networkx-2.8.5 numdifftools-0.9.40 openpyxl-3.0.10 pint-0.19.2 ply-3.11 pyomo-6.4.1 python-louvain-0.16 pyyaml-6.0 sympy-1.10.1 xlrd-2.0.1 z3-solver-4.10.2.0

While trying to install its solver ipopt on databricks getting the folloing error -

Collecting ipopt
  Downloading ipopt-1.0.3.tar.gz (42 kB)
     |████████████████████████████████| 42 kB 1.1 MB/s  eta 0:00:01
    ERROR: Command errored out with exit status 1:
     command: /databricks/python3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-zpxip7hb
         cwd: /tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/
    Complete output (13 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py", line 194, in <module>
        ext_module_data = handle_ext_modules_general_os()
      File "/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py", line 173, in handle_ext_modules_general_os
        **pkgconfig("ipopt"))
      File "/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py", line 100, in pkgconfig
        output = sp.Popen(["pkg-config", "--libs", "--cflags"] + list(packages),
      File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'
Downloading ipopt-0.1.3.zip (109 kB)
     |████████████████████████████████| 109 kB 56.6 MB/s eta 0:00:01
Building wheels for collected packages: ipopt
  Building wheel for ipopt (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /databricks/python3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_97_jyim/ipopt_8a62a84a8dcf4bc5a832cb6bb3713b52/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_97_jyim/ipopt_8a62a84a8dcf4bc5a832cb6bb3713b52/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8pgnfwqa
       cwd: /tmp/pip-install-_97_jyim/ipopt_8a62a84a8dcf4bc5a832cb6bb3713b52/
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/ipopt
  copying ipopt/__init__.py -> build/lib.linux-x86_64-3.8/ipopt
  running build_ext
  skipping 'src/cyipopt.c' Cython extension (up-to-date)
  building 'ipopt.cyipopt' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/amitibo/code/Ipopt-3.10.1/include/coin -I/databricks/python3/lib/python3.8/site-packages/numpy/core/include -I/databricks/python3/include -I/usr/include/python3.8 -c src/cyipopt.c -o build/temp.linux-x86_64-3.8/src/cyipopt.o
  In file included from /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1944,
                   from /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from src/cyipopt.c:237:
  /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     17 | #warning "Using deprecated NumPy API, disable it with " \
        |  ^~~~~~~
  src/cyipopt.c:239:10: fatal error: IpStdCInterface.h: No such file or directory
    239 | #include "IpStdCInterface.h"
        |          ^~~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Note - running databricks on azure.

user22
  • 112
  • 1
  • 9
  • Accoring to [this documentation](https://pypi.org/project/ipyopt/#:~:text=ipyopt%20is%20a%20Python%20%F0%9F%90%8D%20C++%20extension%20that,dimensional.%20Goal.%20Provide%20as%20much%20performance%20as%20possible.), `ipyopt` allows users to utilize `ipopt` in python. Try installing it using `pip install ipyopt` and confirm if this works for you? – Saideep Arikontham Aug 09 '22 at 08:42
  • hey installation worked for ipyopt but still getting this issue - WARNING: Could not locate the 'ipopt' executable, which is required for solver ipopt. ApplicationError: No executable found for solver 'ipopt' – user22 Aug 09 '22 at 09:45

2 Answers2

2

After trying several different ways to install ipopt what worked for me in an Azure Databricks notebook is

cd /tmp
wget https://ampl.com/dl/open/ipopt/ipopt-linux64.zip
unzip ipopt-linux64.zip
chmod +x ipopt
mv ipopt /usr/local/bin

And then when creating the solver point it to the path of ipopt

solver = pe.SolverFactory('ipopt', executable='/usr/local/bin/ipopt')

Even though ipopt was in my path I had to do that.

I tried compiling following this https://coin-or.github.io/Ipopt/INSTALL.html but it would never put the binary in /usr/local/bin. Also installing via apt-get or pip didn't work

gary69
  • 3,620
  • 6
  • 36
  • 50
  • 1
    hey I tested the same on Azure databricks and it worked totally fine for me. Thanks for your help – user22 Oct 17 '22 at 11:27
0

After much trial and error I found that, in order to use the 'ipopt' solver with pyomo during the optimization process, you first need to complete the following steps:

  1. Create an AMPL account and activate a free license by visiting the following link: https://ampl.com/ce. Make sure you safely copy your license UUID for later use.

  2. Go to the terminal and activate the appropriate virtual environment for your project.

  3. Run each of the following commands: python -m pip install amplpy --upgrade python -m amplpy.modules install coin python -m amplpy.modules activate XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (replace Xs with your license UUID)

  4. At this point, your license should be activated. You may need to restart AMPL before using the activated license.

  5. Finally, type the following command in the terminal and copy the resulting path for the 'ipopt' solver executable file. You will need to add this path in in your Python code when calling the solver, i.e. opt = SolverFactory('ipopt', executable='/my/path/ipopt'): python -m amplpy.modules find ipopt

This should work without much issue. Hope this helps, nothing worked for me until I found this on the AMPL website. Also, remember that the module 'coin' has 'ipopt' inside as one of the solvers (there is no 'ipopt' module).

starball
  • 20,030
  • 7
  • 43
  • 238
eurojourney
  • 71
  • 1
  • 9