madebr / pyOpt

Fork of http://www.pyopt.org/ (python3 compatible)
Other
83 stars 35 forks source link

I cannot import any solver - For example SLSQP or NSGA2. Attribute does not exists #10

Open tjlca opened 4 years ago

tjlca commented 4 years ago

from pyOpt import NSGA2 ImportError: cannot import name 'NSGA2' from 'pyOpt' (/Users/tghosh/Downloads/pyOpt-master/pyOpt/__init__.py)

File "<ipython-input-26-0efd7093218e>", line 1, in <module> from pyOpt import SLSQP ImportError: cannot import name 'SLSQP' from 'pyOpt' (/Users/tghosh/Downloads/pyOpt-master/pyOpt/__init__.py) from pyOpt import pySLSQP This works but object created using pySLSQP does not take an optimization problem as a parameter.


slsqp = pyOpt.pySLSQP
[fstr, xstr, inform] = slsqp(opt_prob,sens_type='FD')

TypeError: 'module' object is not callable
madebr commented 4 years ago

pyOpt.pySLSQP is the name of the module. You want to use pyOpt.SLSQP instead.

Have you built the modules? You should run python setup.py build_ext prior to using and installing pyOpt.

TimSuter commented 3 years ago

I have a similar issue. I managed to install pyOpt on my system (Ubuntu 20.04, python 3.8.5, gcc9) without errors and I ran python setup.py build_ext as suggested above before installing pyOpt by running python setup.py install. However when I want to run the example tp037.py I get the following error:

Traceback (most recent call last):
  File "tp037.py", line 98, in <module>
    from pyOpt import ALGENCAN
ImportError: cannot import name 'ALGENCAN' from 'pyOpt' (/home/tim/Downloads/Fit-TDS-master/py3-env/lib/python3.8/site-packages/pyOpt/__init__.py)

Do you have any advice?

e-dub commented 3 years ago

Looks like it was not installed correctly. Check for errors on your build.

zzhya commented 3 months ago

Did you fix it?