Numba TypeError:'output_dir'必须是字符串或None

时间:2016-09-13 10:35:37

标签: python jit numba

我正在尝试研究如何使用Numba的编译代码(Python 2.7.12上的版本0.28.1 + 0.gfe99fbc.dirty | Anaconda custom(64位))。我尝试从文档中运行示例代码:

from numba.pycc import CC
import numpy as np
cc = CC('my_module')
# Uncomment the following line to print out the compilation steps
#cc.verbose = True

@cc.export('centdiff_1d', 'f8[:](f8[:], f8)')
def centdiff_1d(u, dx):
    D = np.empty_like(u)
    D[0] = 0
    D[-1] = 0
    for i in range(1, len(D) - 1):
        D[i] = (u[i+1] - 2 * u[i] + u[i-1]) / dx**2
    return D

if __name__ == "__main__":
    cc.compile()

但是它给出了以:

结尾的错误消息
/projects/py/numba$ python derivatives.py 
In file included from /home/ohm/anaconda2/lib/python2.7/site-packages/numba/pycc/modulemixin.c:16:0:
/home/ohm/anaconda2/lib/python2.7/site-packages/numba/pycc/../_helperlib.c: In function ‘import_cython_function’:
/home/ohm/anaconda2/lib/python2.7/site-packages/numba/pycc/../_helperlib.c:555:42: warning: passing argument 2 of ‘PyMapping_GetItemString’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     cobj = PyMapping_GetItemString(capi, function_name);
                                          ^
In file included from /home/ohm/anaconda2/include/python2.7/Python.h:133:0,
                 from /home/ohm/anaconda2/lib/python2.7/site-packages/numba/pycc/../_pymodule.h:6,
                 from /home/ohm/anaconda2/lib/python2.7/site-packages/numba/pycc/modulemixin.c:8:
/home/ohm/anaconda2/include/python2.7/abstract.h:1356:29: note: expected ‘char *’ but argument is of type ‘const char *’
      PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key);

这里发生了什么?

0 个答案:

没有答案