使用collowing命令-在数据块上成功安装pyomo
pip install 'pyomo[optional]'
输出-成功安装算法-0.5.7 casadi-3.5.5 dill-0.3.5.1 et-xmlfile-1.1.0 mpmath-2.1 networkx-2.8.5 numdifftools-0.9.40 openpyxl-3.0.10 pint--0.12 ply-3.11 pyomo-6.4.1 python-luwain-0.16 pyyaml-6.0 symply-1.10.1 xlrd-2.0.1 z3-solver4.10.2.0
当试图在数据块上安装其解算器ipopt时,出现以下错误-
Collecting ipopt
Downloading ipopt-1.0.3.tar.gz (42 kB)
|████████████████████████████████| 42 kB 1.1 MB/s eta 0:00:01
ERROR: Command errored out with exit status 1:
command: /databricks/python3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-zpxip7hb
cwd: /tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/
Complete output (13 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py", line 194, in <module>
ext_module_data = handle_ext_modules_general_os()
File "/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py", line 173, in handle_ext_modules_general_os
**pkgconfig("ipopt"))
File "/tmp/pip-install-_97_jyim/ipopt_5ccc28f94eb5408181b160df9c422798/setup.py", line 100, in pkgconfig
output = sp.Popen(["pkg-config", "--libs", "--cflags"] + list(packages),
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'pkg-config'
Downloading ipopt-0.1.3.zip (109 kB)
|████████████████████████████████| 109 kB 56.6 MB/s eta 0:00:01
Building wheels for collected packages: ipopt
Building wheel for ipopt (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /databricks/python3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_97_jyim/ipopt_8a62a84a8dcf4bc5a832cb6bb3713b52/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_97_jyim/ipopt_8a62a84a8dcf4bc5a832cb6bb3713b52/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8pgnfwqa
cwd: /tmp/pip-install-_97_jyim/ipopt_8a62a84a8dcf4bc5a832cb6bb3713b52/
Complete output (25 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/ipopt
copying ipopt/__init__.py -> build/lib.linux-x86_64-3.8/ipopt
running build_ext
skipping 'src/cyipopt.c' Cython extension (up-to-date)
building 'ipopt.cyipopt' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/amitibo/code/Ipopt-3.10.1/include/coin -I/databricks/python3/lib/python3.8/site-packages/numpy/core/include -I/databricks/python3/include -I/usr/include/python3.8 -c src/cyipopt.c -o build/temp.linux-x86_64-3.8/src/cyipopt.o
In file included from /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarraytypes.h:1944,
from /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from src/cyipopt.c:237:
/databricks/python3/lib/python3.8/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
17 | #warning "Using deprecated NumPy API, disable it with "
| ^~~~~~~
src/cyipopt.c:239:10: fatal error: IpStdCInterface.h: No such file or directory
239 | #include "IpStdCInterface.h"
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
注意-在azure上运行databricks。
在尝试了几种不同的方法安装ipopt
后,在Azure Databricks笔记本中对我有效的是
cd /tmp
wget https://ampl.com/dl/open/ipopt/ipopt-linux64.zip
unzip ipopt-linux64.zip
chmod +x ipopt
mv ipopt /usr/local/bin
然后在创建解算器时,将其指向ipopt
的路径
solver = pe.SolverFactory('ipopt', executable='/usr/local/bin/ipopt')
即使ipopt
在我的道路上,我也必须这样做。
我试着按照这个编译https://coin-or.github.io/Ipopt/INSTALL.html但是它永远不会将二进制放入CCD_ 4中。同样,通过apt-get
或pip
进行安装也不起的作用
经过多次尝试和错误,我发现,为了在优化过程中使用带有pyomo的"ipopt"求解器,您首先需要完成以下步骤:
-
通过访问以下链接创建AMPL帐户并激活免费许可证:https://ampl.com/ce.请确保安全地复制您的许可证UUID以备日后使用。
-
转到终端并为您的项目激活适当的虚拟环境。
-
运行以下每个命令:python-m pip安装amplpy--升级python-m amplpy.modules安装coinpython-m amplpy.modules激活XXXXXXXXXXXXXXXXXXXXXXXXXXXX(用您的许可UUID替换X(
-
此时,您的许可证应该已激活。在使用激活的许可证之前,您可能需要重新启动AMPL。
-
最后,在终端中键入以下命令,并复制"ipopt"解算器可执行文件的结果路径。调用解算器时,您需要在Python代码中添加此路径,即opt=SolverFactory('popt',executed='/my/path/ippot'(:python-m amplpy.modules查找ipopt
这应该不会有太多问题。希望这能有所帮助,直到我在AMPL网站上发现这一点,我才明白。此外,请记住,模块"coin"内部有作为解算器之一的"ipopt"(没有"iPod"模块(。