2015-06-02 122 views
0

這是numbaNumba: '模塊' 對象沒有屬性 'global_variables'

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' 

我的康達版本是

numba      0.18.2    np19py27_1 
numbapro     0.18.0    np19py27_p2 
llvmlite     0.4.0     py27_0 

你有同樣的問題嗎?幫幫我..

+0

這可能是一個兼容性問題 - 請參閱這個線程:https://github.com/numba/numba/issues/992 –

回答

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 

而且代碼運行良好。

相關問題