打开第二个Syder闪退的问题
我碰到的问题是,当打开第二个Spyder,软件刚打开展现出完整页面就闪退了,提示信息如下:
C:\Windows\System32>spyder --new instance
Traceback (most recent call last):
File "D:\ProgramData\Anaconda3\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\start.py", line 251, in main
mainwindow.main(options, args)
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1992, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\utils.py", line 292, in create_window
main.post_visible_setup()
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1222, in post_visible_setup
self.projects.reopen_last_project()
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\projects\plugin.py", line 578, in reopen_last_project
self.open_project(path=current_project_path,
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\projects\plugin.py", line 433, in open_project
project_type_class = self._load_project_type_class(path)
File "D:\ProgramData\Anaconda3\lib\site-packages\spyder\plugins\projects\plugin.py", line 864, in _load_project_type_class
config.read(fpath)
File "D:\ProgramData\Anaconda3\lib\configparser.py", line 697, in read
self._read(fp, filename)
File "D:\ProgramData\Anaconda3\lib\configparser.py", line 1017, in _read
for lineno, line in enumerate(fp, start=1):
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 297: illegal multibyte sequence
搜索了很多帖子,里面说修改某个文件夹中的特定文件,就可以解决,试过以后还是闪退。
但可以确定的是,这是由于编码格式而造成的,其次,错误提示中给出了出错的文件及出现错误的位置,因此找到这个文件,并修改相应的内容就可以了。
找到这个文件,在指定位置添加,encoding = “utf-8”,就可以了。之前添加,encoding = "GBK"仍然闪退。
修改完毕的文件如下:
for filename in filenames:
try:
with open(filename,encoding = "utf-8") as fp: # encoding=encoding (修改前的代码)
self._read(fp, filename)
except OSError:
continue
if isinstance(filename, os.PathLike):
filename = os.fspath(filename)
read_ok.append(filename)
再次启动,问题解决