未知类型名称'glp_long'(mac osx python,pyglpk)

时间:2013-07-11 12:13:48

标签: python c macos glpk

我正在尝试安装pyglpk-0.3以与cobrapie一起使用,它是matlab眼镜蛇工具箱的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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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