【发布时间】:2016-10-07 21:01:21
【问题描述】:
通过编译源代码并安装 Cython 在 OS X 上安装 SCIP 优化套件后,
make
make install INSTALLDIR="/usr/local/"
make SHARED=true GMP=false READLINE=false scipoptlib
pip install Cython
尝试安装PySCIPOpt
git clone https://github.com/SCIP-Interfaces/PySCIPOpt.git
cd PySCIPOpt
$ SCIPOPTDIR=./ python setup.py install
但这给出了一个错误。有什么建议吗?
Traceback (most recent call last):
File "setup.py", line 29, in <module>
scipsrcdir = sorted(scipsrcdir)[-1] # use the latest version
IndexError: list index out of range
导入库问题
成功安装pyscipopt后,正在使用导入库时
from pyscipopt.scip import Model
我收到 Library not loaded 错误
File "test.py", line 1, in <module>
from pyscipopt import Model
File "/Users/test/anaconda/envs/test/lib/python2.7/site-packages/pyscipopt/__init__.py", line 3, in <module>
from pyscipopt.scip import Model
ImportError: dlopen(/Users/test/anaconda/envs/test/lib/python2.7/site-packages/pyscipopt/scip.so, 2): Library not loaded: lib/libscipopt-3.2.1.darwin.x86_64.gnu.opt.so
Referenced from: /Users/test/anaconda/envs/test/lib/python2.7/site-packages/pyscipopt/scip.so
Reason: image not found
经过一番搜索,我尝试了某人的解决方案:
export DYLD_LIBRARY_PATH=/path/to/scipoptsuite-3.2.1/lib
但再次运行 Python 文件会出现不同的错误 Symbol not found: _history_length
Traceback (most recent call last):
File "test.py", line 1, in <module>
from pyscipopt import Model
File "/Users/test/anaconda/envs/test/lib/python2.7/site-packages/pyscipopt/__init__.py", line 3, in <module>
from pyscipopt.scip import Model
ImportError: dlopen(/Users/test/anaconda/envs/test/lib/python2.7/site-packages/pyscipopt/scip.so, 2): Symbol not found: _history_length
Referenced from: /Users/test/Desktop/scipoptsuite-3.2.1/lib/libscipopt-3.2.1.darwin.x86_64.gnu.opt.so
Expected in: flat namespace
in /Users/test/Desktop/scipoptsuite-3.2.1/lib/libscipopt-3.2.1.darwin.x86_64.gnu.opt.so
【问题讨论】:
-
_history_length 听起来像是 SCIP 的 readline 依赖。也许只是用 READLINE=false 重建 SCIP optsuite,因为无论如何 Python 接口都不需要 readline。
-
@stefan 我用
make SHARED=true GMP=false READLINE=false scipoptlib重建它,但它仍然给出相同的错误 -
@Nyxynyx 您可能会尝试在生成并抛出错误的
scip.so库上运行otool -L。这样您应该能够看到对其他库的未定义引用。 -
遇到同样的问题并导出 DYLD_LIBRARY_PATH= ... 帮助了我。
标签: python macos python-2.7 scip