spikeinterface: The following coding errors will occur when the Chinese system is used
When running the following code, if the Chinese system is used, the following error will be reported

UnicodeDecodeError Traceback (most recent call last) Cell In[3], line 2 1 print(“Available sorters”, ss.available_sorters()) ----> 2 print(“Installed sorters”, ss.installed_sorters())
File e:\anaconda\envs\spike\lib\site-packages\spikeinterface\sorters\sorterlist.py:65, in installed_sorters() [62](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/sorterlist.py:62) def installed_sorters(): [63](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/sorterlist.py:63) “”“Lists installed sorters.”“” —> [65](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/sorterlist.py:65) return sorted([s.sorter_name for s in sorter_full_list if s.is_installed()])
File e:\anaconda\envs\spike\lib\site-packages\spikeinterface\sorters\sorterlist.py:65, in <listcomp>(.0) [62](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/sorterlist.py:62) def installed_sorters(): [63](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/sorterlist.py:63) “”“Lists installed sorters.”“” —> [65](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/sorterlist.py:65) return sorted([s.sorter_name for s in sorter_full_list if s.is_installed()])
File e:\anaconda\envs\spike\lib\site-packages\spikeinterface\sorters\external\hdsort.py:92, in HDSortSorter.is_installed(cls) [90](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/external/hdsort.py:90) @classmethod [91](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/external/hdsort.py:91) def is_installed(cls): —> [92](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/external/hdsort.py:92) if cls.check_compiled(): [93](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/external/hdsort.py:93) return True [94](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/external/hdsort.py:94) return check_if_installed(cls.hdsort_path)
File e:\anaconda\envs\spike\lib\site-packages\spikeinterface\sorters\basesorter.py:375, in BaseSorter.check_compiled(cls) [367](file:///E:/anaconda/envs/spike/lib/site-packages/spikeinterface/sorters/basesorter.py:367) shell_cmd = f"“” … –> [322](file:///E:/anaconda/envs/spike/lib/codecs.py:322) (result, consumed) = self._buffer_decode(data, self.errors, final) [323](file:///E:/anaconda/envs/spike/lib/codecs.py:323) # keep undecoded input until the next call [324](file:///E:/anaconda/envs/spike/lib/codecs.py:324) self.buffer = data[consumed:]
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb2 in position 5: invalid start byte Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings…
I solved this problem by adding the following code to shellscript.py. Is there a better solution?
add encoding='gbk' when using subprocess.Popen
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 21 (14 by maintainers)
I just changed the system’s default encoding to “UTF-8” by a new approach, specifically by selecting “Beta: Use Unicode UTF-8 to provide worldwide language support” in the system region settings (Win10 22H2, Chinese version); Chinese users can refer to the link https://blog.csdn.net/robinhunan/article/details/106047345.
After making this setting, the default encoding of the shell has also switched to “UTF-8”. Under this circumstance, This issue #3429 no longer causes errors, and i think spikeInterface may not need to be modified.