OpenMDAO + PyOptSparse兼容性
问题描述:
我想使用PyOptSparse驱动程序。我已经成功安装了该软件包,但是使用了Python 2.7。OpenMDAO + PyOptSparse兼容性
Lorens-MacBook-Pro:code lorensheets$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyoptsparse import Optimization
>>>
我的OpenMDAO安装使用Python 3.6。当我尝试虽然导入模块,这是我看到的错误:
>>> from openmdao.drivers.pyoptsparse_driver import pyOptSparseDriver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openmdao/drivers/pyoptsparse_driver.py", line 17, in <module>
from pyoptsparse import Optimization
ModuleNotFoundError: No module named 'pyoptsparse'
>>>
我已经试过了OpenMDAO安装使用Python 2.7,但我似乎无法得到它的工作。以下是错误:
ImportError: No module named configparser
是否要与python3安装,以便与OpenMDAO工作pyoptsparse需要,或者我需要得到OpenMDAO到与Python 2.7正常工作?还是有什么我失踪?
答
是的,pyoptsparse是一个外部包。你可以得到它from here.如果你在2.7环境中安装了某些东西,它将不能在3中使用,所以你需要在那里重新安装它。
对于2.7,它看起来像你还需要configparser。我认为这是2.7版本的问题,但也许是2.7.x以后的版本。无论如何,你应该能够用点安装它:
pip install configparser
肯尼斯,感谢您的信息。用Python3重新安装pyoptsparse。 使用NSGA2优化时,现在收到此错误: “”“pyOptSparse错误:有一个错误导入编译NSGA2 模块”“” 得到同样的错误,每pyoptsparse优化 –
这听起来像你的模块没”正确构建。确保你在pyoptsparse目录中执行了'python setup.py build'。你是否收到任何消息说明没有编译C或Fortran代码? –