So I am opening this new thread about how to build pyOptSparse and use it within the OpenMDAO framework. The OpenMDAO team released a scrip which should build pyOptSparse by integrating IPOPT as well: https://github.com/OpenMDAO/build_pyoptsparse
I followed their instructions on a Ubuntu virtual machine. Unfortunately, when it comes to run the scrip, something goes wrong and prevent pyOptSparse to be installed.
I don’t know if I am forgetting something, but I am stuck. Does anyone know how to solve this problem ?
Many thanks in advance for your help. Here is the strange error message that I got this:
File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command ‘[‘./configure’, ‘–with-metis’, ‘–with-metis-lflags=-L/root/pyoptsparse/lib -lcoinmetis’, ‘–with-metis-cflags=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis’, ‘–prefix=/root/pyoptsparse’, ‘CFLAGS=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis’, ‘FCFLAGS=-fallow-argument-mismatch -w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis’]’ returned non-zero exit status 1.
EDIT: So I ran build_pyoptsparse -v twice: the first time I got an error message which were telling me that the package LAPCK was missing. Therefore, I did an apt-get install libblas-dev liblapack-dev to install it. Then I ran again the pyoptsparse command and I got this:
...
checking for LAPACK... yes: generic module (lapack.pc blas.pc)
checking for function dgemmt_ in -llapack -lblas ... no
checking for function dgemmt in -llapack -lblas ... no
checking for function DGEMMT_ in -llapack -lblas ... no
checking for function DGEMMT in -llapack -lblas ... no
checking for function dgemmt__ in -llapack -lblas ... no
checking for function dgemmt_ in -llapack -lblas ... no
checking for function DGEMMT__ in -llapack -lblas ... no
checking for function DGEMMT_ in -llapack -lblas ... no
checking for library containing cos... -lm
checking for library Metis with combined link and compile check... no (link with header)
configure: Compiler flags were "-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis". Use --with-metis-cflags to overwrite. Check config.log for details of failed compile attempt.
configure: Linker flags are "-L/root/pyoptsparse/lib -lcoinmetis". Use --with-metis-lflags to overwrite. Check config.log for details of failed link attempt.
configure: error: user-specified flags for Metis do not work.
Traceback (most recent call last):
File "/usr/local/bin/build_pyoptsparse", line 8, in <module>
sys.exit(perform_install())
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 1118, in perform_install
install_with_mumps()
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 642, in install_with_mumps
install_mumps_from_src()
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 579, in install_mumps_from_src
run_cmd(cmd_list=cnf_cmd_list)
File "/usr/local/lib/python3.9/site-packages/build_pyoptsparse.py", line 335, in run_cmd
subprocess.run(cmd_list, check=do_check)
File "/usr/local/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['./configure', '--with-metis', '--with-metis-lflags=-L/root/pyoptsparse/lib -lcoinmetis', '--with-metis-cflags=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis', '--prefix=/root/pyoptsparse', 'CFLAGS=-w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis', 'FCFLAGS=-fallow-argument-mismatch -w -I/root/pyoptsparse/include -I/root/pyoptsparse/include/coin-or -I/root/pyoptsparse/include/coin-or/metis']' returned non-zero exit status 1.
2
Answers
The
build_pyoptsparse
script was intended to be run as a normal user rather than root – it hasn’t been tested that way and may have unintended impacts on your system.Ideally it should be run in a virtual Python environment, either with
conda
(Anaconda / miniconda / miniforge) orvenv
. In aconda
environment, several of the packages can be installed from the repository rather than having to build them. If run outside of a virtual environment, it will install under your home directory. The exact path can be modified with-p
.Having said that, there’s not a lot of info in your screenshot except that an error occurred. If there’s a different version of METIS already installed on your system, that could be causing problems with the MUMPS configuration. Try removing the other version of METIS and building again. If you’re still getting an error, run
build_pyoptsparse -v
so that the complete error text is printed, and post it here.I ran into a similar issue when trying to install this package to use it with openmdao/dymos. I’m using Linux Mint with conda 22.9.0. These are the steps that I followed to fully set up my environment, answering yes to all prompts:
close your shell and reopen it