xuy/pyipopt

from pyipoptcore import * --> libipopt.so.1: cannot open shared object file: No such file or directory

baothien opened this issue · 6 comments

Hi,

I tried to install pyipopt, it seems that everything is ok. Then I run the test file examples/hs071.py, this error happens. After that, I try just to "import pyipopt" from python, and the same error.

I open the folder pyipoptpackage and there are only ipoptconst.py and ipoptunconstrained.py, without the pyipoptcore.py file.

I am a new babie with pyipot and ipopt, so if anyone can help me or give me a hint how to solve it, all are very appreciated.

Hi baothien,

Here is what worked for me
0. Install Ipopt in the following way (based on http://www.coin-or.org/Ipopt/documentation/node13.html & http://www.coin-or.org/Ipopt/documentation/node14.html):
0.0 Remove Ipopt using: make clean; make uninstall ## use, if necessary, sudo make uninstall
0.1 cd $IPOPTDIR/ThirdParty/Blas;./get.Blas;cd ../Lapack;./get.Lapack # installing external code
0.2 mkdir $IPOPTDIR/build; cd $IPOPTDIR/build
0.3 ../configure --prefix=/usr/local/ # Note that I intend to install ipopt in the /usr/local/ directory
0.4 make
0.5 sudo make install

  1. After installing, Ipopt, uninstall pyipopt if you had installed it earlier. For this, you need to remove all files. Type on the terminal: sudo rm -rf /usr/local/lib/python2.7/dist-packages/pyipopt*
  2. Then just follow the steps on https://github.com/xuy/pyipopt. I did the following:
    2.1 git clone http://github.com/xuy/pyipopt.git
    2.2 cd pyipopt
    -----> 2.3 sudo ldconfig # This is a crucial step that solved my problem.
    2.4 python setup.py build # Note that the default setup.py file is fine. It looks for the links for files like libipopt.so.1 in /usr/local
    2.5 sudo python setup.py install

Now the toy example works.
python hs071_sam.py

All the best.

Sam

for future reference, if you happen to be installing IpOpt and pyipopt on a remote machine where you don't have root or can't 'sudo' (in my case, a compute cluster), the 'ldconfig' step won't work (since it needs to modify /etc/ld.so.cache)
Add instead the path to the ipopt shared libraries (e.g. ..CoinOpt/build/lib) to the bash variable LD_LIBRARY_PATH, e.g. by adding this line to your ~/.profile or ~/.bashrc :

export <...>CoinIpopt/build/lib:$LD_LIBRARY_PATH

Is it possible to pack all .so files in CoiIpopt/build/lib/* into pyipoptcore.so? That is, to make the build directory self-contained with the pyipopt module?

I need this because I want to make the pyipopt module independent of any LD_LIBRARY_PATH update, if IPOPT is not installed as sudo?

Sam

fhchl commented

For the record: after installing exactly as @samiit describes I got the following error when running the example files with a anaconda3 distro

ImportError: /home/fmheu/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/lib/libipopt.so.0)

Solved by

conda install libgcc

I spend two days trying to install this package in order to use anaconda with python3.6 in Pycharm. The easy way is to run the above mentioned commands in the PyCharm terminal, because when I run the command on the system terminal, PyIPOPT always was installed in python2.7.

pf4d commented