【问题标题】:AssertionError: Failed in nopython mode pipeline (step: analyzing bytecode)AssertionError: Failed in nopython mode pipeline(步骤:分析字节码)
【发布时间】:2019-08-21 01:02:20
【问题描述】:

我编写了一个 Python 程序来循环一个 csv 数据文件并生成一个新的 csv 文件。为了减少运行时间,我尝试使用 numba,下面是我的代码:

import csv
import timeit
from numba import jit
@jit(nopython=True)
def main():
    file = open("test_data.csv","r")
    newfile = open("rewrite5_gpu_output.csv",'w', newline='')
    writer = csv.writer(newfile)
    dataframe = []
    start = timeit.default_timer()
    for line in file:
        new_line = []
        line = line.split(",")
        for item in line:
            if item == '\n':
                pass
            elif item == "active":
                new_line.append(1) # 1 = active p53
            elif item == "inactive":
                new_line.append(0) # 0 = inactive p53
            else:
                try:
                    item = item.strip('\n')
                    item = float(item)
                    new_line.append(item)
                except:
                    pass
        dataframe.append(new_line)
        #print(new_line)
    writer.writerows(dataframe)
    newfile.close()
    stop = timeit.default_timer()
    print('Time: ', stop - start)

main()

但是,我得到了错误:

AssertionError: Failed in nopython mode pipeline (step: analyzing bytecode)
SETUP_EXCEPT(arg=32, lineno=23)

【问题讨论】:

    标签: python-3.x numba


    【解决方案1】:

    尝试注释掉“try:”和“except:”。 在其他一些帖子中,我读过尝试- numba.jit 不支持除外 它在我的 python 脚本中工作。

    br,

    【讨论】:

      猜你喜欢
      • 2021-06-15
      • 2019-06-17
      • 2020-07-15
      • 2019-07-30
      • 2023-02-01
      • 2019-11-13
      • 1970-01-01
      • 2021-07-21
      • 2021-08-21
      相关资源
      最近更新 更多