>我正在运行单元格类型笔记本的第一行:
sweep_number = 30
sweep_data = data_set.get_sweep(sweep_number)
我收到此错误:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-8-1ff88b13fc24> in <module>()
4
5 sweep_number = 30
----> 6 sweep_data = data_set.get_sweep(sweep_number)
7
C:ProgramDataAnaconda3libsite-packagesallensdkcorenwb_data_set.py in get_sweep(self, sweep_number)
112 unit = stimulus_dataset.attrs["unit"]
113 unit_str = None
--> 114 if unit.startswith('A'):
115 unit_str = "Amps"
116 elif unit.startswith('V'):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
您
看到的错误是由以下事实引起的:unit
变量是字节文本,并且allensdk
尝试使用其上的字符串调用endswith
。这行不通,但这不是你的错。这是从 Python 2 迁移到 Python 3 时的常见错误(引入了字节类型;有关详细信息,请参阅此处(。我猜你正在运行Python 3,这会导致错误,因为allensdk在这里不能处理字节。
要解决此问题,您必须安装 Python 2,因为您使用的是 conda,请创建一个使用 Python 2 的环境。这可以按如下方式完成:
> conda create -n py2allen python=2.7
> activate py2allen
(py2allen)> pip install allensdk
(py2allen)> jupyter notebook
更多信息可以在这里找到。如果未找到某些要求,可以尝试手动安装它们。