尝试使用Openopt
的{{1}}解决Python中的非线性问题时,我收到此错误,摘要为
你应该安装DerApproximator。
我试过
NLP.solve()
但它说“要求已经满足”。
我使用的是Windows 7 x64,Python 3.4和OpenOpt 0.5604。如何安装此软件包?
pip install derapproximator
我在solution = problem.solve('ralg')
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\baseProblem.py", line 253, in solve
return runProbSolver(self, *args, **kwargs)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\runProbSolver.py", line 292, in runProbSolver solver(p)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\solvers\UkrOpt\ralg_oo.py", line 159, in __solver__
g = bestPoint._getDirection(self.approach)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\Point.py", line 640, in _getDirection
self.direction = self.sum_of_all_active_constraints_gradient()
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\Point.py", line 565, in sum_of_all_active_constraints_gradient
tmp = p.dc(x, ind)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\baseProblem.py", line 550, in <lambda>
self.wrapped_1st_derivatives(x, ind, funcType, ignorePrev, useSparse))
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\nonLinFuncs.py", line 383, in wrapped_1st_derivatives
derivatives = p.wrapped_func(x, ind, funcType, True, True)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\nonLinFuncs.py", line 28, in wrapped_func
p.err('For the problem you should have DerApproximator installed, see http://openopt.org/DerApproximator')
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\oologfcn.py", line 16, in ooerr
raise OpenOptException(msg)
oologfcn.OpenOptException: For the problem you should have DerApproximator installed, see http://openopt.org/DerApproximator
路径中看到一个名为derapproximator-0.52-py3.4.egg
的文件,我必须在Python34\Lib\site-packages
中添加PYTHONPATH
密钥,以便在python中找到openopt。我不知道如何在那里使用带有Environment variables
扩展名的文件,因此我将内容提取到.egg
。 cmd树上的文件夹层次结构如何
derapproximator-0.52-py3.4
但错误仍然相同,
+---derapproximator-0.52-py3.4
| +---DerApproximator
| | \---__pycache__
| \---EGG-INFO
然后我再次尝试将文件夹重命名为>>> import derapproximator
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'derapproximator'
,但它仍然不起作用。