Numba:'模块'对象没有属性" global_variables'

时间:2015-06-02 08:59:34

标签: python numba numba-pro

这是numba的基本示例

import numpy as np
from numba import double
from numba.decorators import jit, autojit

X = np.random.random((1000, 3))

def pairwise_python(X):
    M = X.shape[0]
    N = X.shape[1]
    D = np.empty((M, M), dtype=np.float)
    for i in range(M):
        for j in range(M):
            d = 0.0
            for k in range(N):
                tmp = X[i, k] - X[j, k]
                d += tmp*tmp
            D[i, j] = np.sqrt(d)
    return D

pairwise_numba = autojit(pairwise_python)

pairwise_numba(X)

但它会生成错误消息

AttributeError: Failed at object (object mode frontend)
Failed at object (object mode backend)
'Module' object has no attribute 'global_variables'

我的conda版本是

numba                     0.18.2               np19py27_1
numbapro                  0.18.0              np19py27_p2
llvmlite                  0.4.0                    py27_0

你有同样的问题吗?救救我..

1 个答案:

答案 0 :(得分:0)

这很复杂。这是我的解决方案。

$ sudo apt-get install llvm-3.5-dev
$ sudo apt-get install libedit-dev
$ pip install enum34

$ git clone https://github.com/numba/llvmlite
$ cd llvmlite
$ LLVM_CONFIG=/usr/bin/llvm-config-3.5 python setup.py install


$ conda install numba
Fetching package metadata: ....
Solving package specifications: .
Package plan for installation in environment /home/khkim/anaconda/envs/test:

The following packages will be UPDATED:

    numba:    0.17.0-np19py27_0 --> 0.18.2-np19py27_1

The following packages will be DOWNGRADED:

    llvmlite: 0.5.0-py27_0      --> 0.4.0-py27_0

代码运作良好。