gpt4 book ai didi

python - TypeError : exceptions must be old-style classes or derived from BaseException, 不是 NoneType

转载 作者:行者123 更新时间:2023-11-28 18:48:55 54 4
gpt4 key购买 nike

所以今天这让我困惑了太久。我把它扔给你们。

我得到了

TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

即使我只是单独使用 raise 或与 Exception() 一起使用时也是如此

这是完整的追溯,以防有帮助。我晕了...

---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/gus/py274/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
176 else:
177 filename = fname
--> 178 __builtin__.execfile(filename, *where)

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/scripts/blacktie_pipeline.py in <module>()
233
234 if __name__ == "__main__":
--> 235 main()

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/scripts/blacktie_pipeline.py in main()
203 # Prep cuffmerge call
204 ##ipdb.set_trace()
--> 205 cuffmerge_call = CuffmergeCall(yargs,email_info,run_id,run_logs,conditions=experiment,mode=args.mode)
206 cuffmerge_call.execute()
207

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/utils/calls.pyc in __init__(self, yargs, email_info, run_id, run_logs, conditions, mode)
627
628 self.prog_yargs = self.yargs.cuffmerge_options
--> 629 self.set_call_id()
630 self.init_log_file()
631 self.out_dir = self.get_out_dir()

/home/gus/Dropbox/repos/git/blacktie/src/blacktie/utils/calls.pyc in set_call_id(self)
116 self.call_id = call_id
117 else:
--> 118 raise Exception()
119
120 def notify_start_of_call(self):

TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType

最佳答案

好吧,我似乎发现问题不在我自己的代码本身。我一直在 Ipython 中运行脚本:因此是顶层跟踪地址。

我决定从终端运行它,并按预期引发了异常。

我自己回答了这个问题,尽管我仍然不知道为什么 Ipython 会导致这种情况发生,因为这似乎是我应该问的一个单独的问题。

不过,希望这有助于有人看到这种奇怪的行为。

关于python - TypeError : exceptions must be old-style classes or derived from BaseException, 不是 NoneType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16002718/

54 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com