我想弄清楚错误

时间:2018-03-29 13:04:12

标签: python-2.7 function

好吧,我不太确定我需要关注的错误是什么,我假设这是第一个错误,因为参数导致了以下错误。但我想知道这个错误意味着什么。据我所知,try和except用于文件处理/操作。那么这是否意味着错误与/opt/MOST-master/MLST_data/TEST/reference.seq不存在的事实有关?因为我检查过它并不存在,但我认为这是因为它预期存在的文件,但不是因为try的初始错误而且除了。

Traceback (most recent call last):
File "/opt/MOST-master/modules/utility_functions.py", line 243, in try_and_except
return function(*parameters, **named_parameters)
File "/opt/MOST-master/modules/MLST_extract_flanking_region_functions.py", line 74, in flanking_regions
refseq_record = SeqIO.read(reference_fasta_file, "fasta", generic_dna)
File "/usr/lib64/python2.7/site-packages/Bio/SeqIO/__init__.py", line 676, in read
first = next(iterator)
File "/usr/lib64/python2.7/site-packages/Bio/SeqIO/__init__.py", line 592, in parse
with as_handle(handle, mode) as fp:
File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/lib64/python2.7/site-packages/Bio/File.py", line 87, in as_handle
with open(handleish, mode, **kwargs) as fp:
IOError: [Errno 2] No such file or directory: '/opt/MOST-master/MLST_data/TEST/reference.seq'

1 个答案:

答案 0 :(得分:0)

在错误输出中,您会在底部看到错误的直接原因。调用堆栈的顶部显示最外层框架。

例如这个程序

def a(x):
    b(x)

def b(x):
    c(x)

def c(x):
    d(x)

a(3)

产生此错误:

Traceback (most recent call last):
  File "stk.py", line 10, in <module>
    a(3)
  File "stk.py", line 2, in a
    b(x)
  File "stk.py", line 5, in b
    c(x)
  File "stk.py", line 8, in c
    d(x)
NameError: name 'd' is not defined