attributeerror'module'对象没有属性'openfile'

时间:2017-08-14 01:06:48

标签: python

我正在试图找出使用Python发生的错误。我正在尝试使用klustakwik团队免费发布的模块detektspikes.py。

我遇到运行时发生错误的问题。

错误日志:

Exiting directory C:\Users\user\Downloads\klusta-team-spikedetekt-82bcf06\klusta
-team-spikedetekt-82bcf06\scripts_1
Traceback (most recent call last):
File "C:\Users\user\Downloads\klusta-team-spikedetekt-82bcf06\klusta-team-spik
edetekt-82bcf06\scripts\detektspikes.py", line 82, in <module>
spike_detection_job(raw_data_files, probe_file, output_dir, output_name)
File "C:\Python27\lib\site-packages\spikedetekt\core.py", line 86, in 
spike_de
tection_job
probe, max_spikes)
File "C:\Python27\lib\site-packages\spikedetekt\core.py", line 115, in 
spike_d
etection_from_raw_data
h5s[n] = tables.openFile(filename, 'w')
AttributeError: 'module' object has no attribute 'openFile'

我猜问题出现在core.py

Core.py:

 Filter, detect, extract from raw data.
"""
### Detect spikes. For each detected spike, send it to spike writer, which
### writes it to a spk file. List of times is small (memorywise) so we just
### store the list and write it later.

np.savetxt("dat_channels.txt", Channels_dat, fmt="%i")

# Create HDF5 files
h5s = {}
h5s_filenames = {}
for n in ['main', 'waves']:
    filename = basename+'.'+n+'.h5'
    h5s[n] = tables.openFile(filename, 'w')
    h5s_filenames[n] = filename
for n in ['raw', 'high', 'low']:
    if Parameters['RECORD_'+n.upper()]:
        filename = basename+'.'+n+'.h5'
        h5s[n] = tables.openFile(filename, 'w')
        h5s_filenames[n] = filename
main_h5 = h5s['main']
# Shanks groups
shanks_group = {}
shank_group = {}
shank_table = {}
for k in ['main', 'waves']:
    h5 = h5s[k]
    shanks_group[k] = h5.createGroup('/', 'shanks')
    for i in probe.shanks_set:

我很乐意得到善意的帮助!

1 个答案:

答案 0 :(得分:3)

问题是该代码适用于非常旧版本的Python,并尝试访问不再存在的tables方法。见这里:http://www.pytables.org/MIGRATING_TO_3.x.html

如果您想运行该脚本,则必须在旧版本的Python(如2.3)中运行该脚本,或者更新使用openFile的行来代替使用open_file。虽然可能存在其他我不了解的不兼容性。