如果导入以下内容,它将编译为预期的.so文件:
import numba as nb
from numba.pycc import CC
cc = CC('t1')
@nb.njit(parallel=True)
@cc.export('diff', '(f4[:], i8)')
def diff(buffer, half_buffer_size):
for tau in nb.prange(half_buffer_size):
buffer[tau] = 0
@nb.njit
@cc.export('test', '(f4[:], i8)')
def test(buffer, half_buffer_size):
diff(buffer, half_buffer_size)
cc.compile()
已经编译了文件,如果我随后运行再次导入t1的脚本,则会出现以下错误:
Traceback (most recent call last):
File "/Users/me/PycharmProjects/t1/main.py", line 2, in <module>
import t1
ImportError: dlopen(/Users/me/PycharmProjects/t1/t1.cpython-38-darwin.so, 2): Symbol not found: _do_scheduling_unsigned
Referenced from: /Users/me/PycharmProjects/t1/t1.cpython-38-darwin.so
Expected in: flat namespace
in /Users/me/PycharmProjects/t1/t1.cpython-38-darwin.so
这似乎是在测试内调用diff的结果。如果我对此调用进行注释并重新编译,则可以直接从main.py调用diff
,而不会出现任何问题。我该如何解决这个问题?