1

我正在尝试安装 pyglpk-0.3 以将其与 cobrapie(matlab cobra 工具箱的 python 版本)一起使用。每次我开始安装时,都会出现以下错误:(其中的一部分)

c -I/Users/gadreel/anaconda/include/python2.7 -c src/tree.c -o build/temp.macosx-10.5-x86_64-2.7

/src/tree.o -m32
/usr/bin/clang -fno-strict-aliasing -I/Users/gadreel/anaconda/include -arch x86_64 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -Isrc -I/Users/gadreel/anaconda/include/python2.7 -c src/environment.c -o build/temp.macosx-10.5-x86_64-2.7/src/environment.o -m32
src/environment.c:80:26: error: unknown type name 'glp_long'
static PyObject* long2py(GLP_LONG l) {
                         ^
src/environment.c:75:18: note: expanded from macro 'GLP_LONG'
#define GLP_LONG glp_long
                 ^
src/environment.c:90:3: error: use of undeclared identifier 'glp_long'
  GLP_LONG b;
  ^
src/environment.c:75:18: note: expanded from macro 'GLP_LONG'
#define GLP_LONG glp_long
                 ^
src/environment.c:91:30: error: use of undeclared identifier 'b'
  glp_mem_usage(NULL, NULL, &b, NULL);
                             ^
src/environment.c:92:18: error: use of undeclared identifier 'b'
  return long2py(b);
                 ^
src/environment.c:97:3: error: use of undeclared identifier 'glp_long'
  GLP_LONG b;
  ^
src/environment.c:75:18: note: expanded from macro 'GLP_LONG'
#define GLP_LONG glp_long
                 ^
src/environment.c:98:36: error: use of undeclared identifier 'b'
  glp_mem_usage(NULL, NULL, NULL, &b);
                                   ^
src/environment.c:99:18: error: use of undeclared identifier 'b'
  return long2py(b);
                 ^
7 errors generated.
error: command '/usr/bin/clang' failed with exit status 1
make: *** [all] Error 1

这是提到的c文件的一部分:

static PyObject* Environment_getblocks_peak(EnvironmentObject *self,
                       void *closure) {
  int cpeak;
  glp_mem_usage(NULL, &cpeak, NULL, NULL);
  return PyInt_FromLong(cpeak);
}

#if GLPK_VERSION(4,28)
#define GLP_LONG glp_long
#else
#define GLP_LONG glp_ulong
#endif

static PyObject* long2py(GLP_LONG l) {
  if ((l.hi==0 && l.lo>=0) || (l.hi==-1 && l.lo<0))
    return PyInt_FromLong(l.lo);
  PY_LONG_LONG ll = l.hi;
  ll <<= 32;
  ll |= (unsigned int)l.lo;
  return PyLong_FromLongLong(ll);
}

static PyObject* Environment_getbytes(EnvironmentObject *self,void *closure) {
  GLP_LONG b;
  glp_mem_usage(NULL, NULL, &b, NULL);
  return long2py(b);
}

我错过了要安装的东西吗?我使用 Python 2.7.5 |Anaconda 1.6.1 (x86_64)| 和 glpk @4.48_0(活动)与 osx 10.8.4

4

2 回答 2

1

对我来说,我要做的就是将 glpk 降级到 4.39,因为以后的版本你会遇到 glp_long 问题。

于 2014-05-08T15:46:12.990 回答
0

有几个人在 github 上克隆了 pyglpk 代码并将其更新为与最新版本的 glpk 一起使用。我一直在使用https://github.com/bradfordboyle/pyglpk并且知道它适用于 glpk-4.61

于 2017-09-15T03:40:54.150 回答