来自 AllenSDK 的 运行 细胞类型笔记本时出现类型错误
TypeError while running Cell Types notebook from AllenSDK
我是运行第一行cell types notebook:
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:\ProgramData\Anaconda3\lib\site-packages\allensdk\core\nwb_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 时的常见错误(它引入了字节类型;有关详细信息,请参阅 here)。我猜你是 运行 Python 3 这会导致错误,因为 allensdk 无法在此处处理字节。
要解决此问题,您要么必须安装 Python 2,因为您使用的是 conda,请创建一个使用 Python 2 的环境。这可以按如下方式完成:
> conda create -n py2allen python=2.7
> activate py2allen
(py2allen)> pip install allensdk
(py2allen)> jupyter notebook
可以找到更多信息 here。
如果有些需求没有找到,可以尝试手动安装。
我是运行第一行cell types notebook:
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:\ProgramData\Anaconda3\lib\site-packages\allensdk\core\nwb_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 时的常见错误(它引入了字节类型;有关详细信息,请参阅 here)。我猜你是 运行 Python 3 这会导致错误,因为 allensdk 无法在此处处理字节。
要解决此问题,您要么必须安装 Python 2,因为您使用的是 conda,请创建一个使用 Python 2 的环境。这可以按如下方式完成:
> conda create -n py2allen python=2.7
> activate py2allen
(py2allen)> pip install allensdk
(py2allen)> jupyter notebook
可以找到更多信息 here。 如果有些需求没有找到,可以尝试手动安装。