在Mac OSX上安装PySCIPOpt时出错

时间:2016-10-07 21:01:21

标签: python macos python-2.7 scip

在OS X上安装SCIP Optimization Suite后,编译源代码并安装Cython,

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

2 个答案:

答案 0 :(得分:0)

设置SCIPOPTDIR环境变量时,它会查找$ {SCIPOPTDIR} / scip - * / src形式的目录。

您收到该错误,因为您在PySCIPopt.git的新克隆结帐中没有任何与该表单匹配的目录。您需要将该环境变量设置为安装&#34; SCIP Optimization Suite&#34;的目录。

答案 1 :(得分:0)

您需要先安装SCIP。确切地说,SCIP优化套件的共享库。然后必须将环境变量SCIPOPTDIR设置为其根目录 - 而不是Python接口的目录。请仔细按照安装文件中的说明进行操作:https://github.com/SCIP-Interfaces/PySCIPOpt/blob/master/INSTALL.md