I want to use numba package in QGIS. I installed numba in qgis then I want to test a simple code with numba. I used below code from http://numba.pydata.org/
from numba import jit
from numpy import arange
# jit decorator tells Numba to compile this function.
# The argument types will be inferred by Numba when function is called.
@jit
def sum2d(arr):
M, N = arr.shape
result = 0.0
for i in range(M):
for j in range(N):
result += arr[i,j]
return result
a = arange(9).reshape(3,3)
print(sum2d(a))
The result of this code is 36.0
. But in QGIS I received this errors:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/tmp890NMS.py", line 16, in
print(sum2d(a))
File "/usr/local/lib/python2.7/dist-packages/numba/dispatcher.py", line 307, in _compile_for_args
return self.compile(tuple(argtypes))
File "/usr/local/lib/python2.7/dist-packages/numba/dispatcher.py", line 579, in compile
cres = self._compiler.compile(args, return_type)
File "/usr/local/lib/python2.7/dist-packages/numba/dispatcher.py", line 80, in compile
flags=flags, locals=self.locals)
File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 763, in compile_extra
return pipeline.compile_extra(func)
File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 360, in compile_extra
return self._compile_bytecode()
File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 722, in _compile_bytecode
return self._compile_core()
File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 709, in _compile_core
res = pm.run(self.status)
File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 246, in run
raise patched_exception
KeyError: 'Caused By:\nTraceback (most recent call last):\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 238, in run\n stage()\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 431, in stage_objectmode_frontend\n cres = self.frontend_looplift()\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 421, in frontend_looplift\n lifted=tuple(loops), lifted_from=None)\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 777, in compile_ir\n lifted_from=lifted_from)\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 368, in compile_ir\n return self._compile_ir()\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 729, in _compile_ir\n return self._compile_core()\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 709, in _compile_core\n res = pm.run(self.status)\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 246, in run\n raise patched_exception\nKeyError: \'Caused By:\\nTraceback (most recent call last):\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 238, in run\\n stage()\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 622, in stage_objectmode_backend\\n self._backend(lowerfn, objectmode=True)\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 599, in _backend\\n lowered = lowerfn()\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 573, in backend_object_mode\\n self.flags)\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 905, in py_lowering_stage\\n lower = objmode.PyLower(targetctx, library, fndesc, interp)\\n File "/usr/local/lib/python2.7/dist-packages/numba/lowering.py", line 65, in __init__\\n self.env = Environment.from_fndesc(self.fndesc)\\n File "/usr/local/lib/python2.7/dist-packages/numba/lowering.py", line 21, in from_fndesc\\n mod = fndesc.lookup_module()\\n File "/usr/local/lib/python2.7/dist-packages/numba/funcdesc.py", line 77, in lookup_module\\n return sys.modules[self.modname]\\nKeyError: \\\'__console__\\\'\\n\\nFailed at object (object mode backend)\\n\\\'__console__\\\'\'\n\nFailed at object (object mode frontend)\n\'Caused By:\\nTraceback (most recent call last):\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 238, in run\\n stage()\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 622, in stage_objectmode_backend\\n self._backend(lowerfn, objectmode=True)\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 599, in _backend\\n lowered = lowerfn()\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 573, in backend_object_mode\\n self.flags)\\n File "/usr/local/lib/python2.7/dist-packages/numba/compiler.py", line 905, in py_lowering_stage\\n lower = objmode.PyLower(targetctx, library, fndesc, interp)\\n File "/usr/local/lib/python2.7/dist-packages/numba/lowering.py", line 65, in __init__\\n self.env = Environment.from_fndesc(self.fndesc)\\n File "/usr/local/lib/python2.7/dist-packages/numba/lowering.py", line 21, in from_fndesc\\n mod = fndesc.lookup_module()\\n File "/usr/local/lib/python2.7/dist-packages/numba/funcdesc.py", line 77, in lookup_module\\n return sys.modules[self.modname]\\nKeyError: \\\'__console__\\\'\\n\\nFailed at object (object mode backend)\\n\\\'__console__\\\'\''
With this error,Can I use numba in QGIS or not?
No comments:
Post a Comment