首页 > 解决方案 > numba.core.errors.TypingError:在 uuid.uuid1() 的 nopython 模式管道(步骤:nopython 前端)中失败

问题描述

发生numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend),当我使用numba加速python时。

基本信息是

python 3.7.9
numba 0.52.0

代码是

@numba.jit(nopython=True)
def add_uuid(*args) -> str:
    random_id = uuid.uuid1()
    return '_'.join(args) + '_' + str(random_id)

错误详细信息是

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "map_client.py", line 55, in __init__
    self._map_id = string_util.add_uuid('map_task', job_name)
  File "~/.local/share/virtualenvs/map-aGUXCO1N/lib/python3.7/site-packages/numba/core/dispatcher.py", line 414, in _compile_for_args
    error_rewrite(e, 'typing')
  File "~/.local/share/virtualenvs/map-aGUXCO1N/lib/python3.7/site-packages/numba/core/dispatcher.py", line 357, in error_rewrite
    raise e.with_traceback(None)
numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Unknown attribute 'uuid1' of type Module(<module 'uuid' from '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/uuid.py'>)

标签: pythonnumba

解决方案


推荐阅读