您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關anaconda spyder出錯怎么辦,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
anaconda spyder出錯解決:
寫Python程序時突然遇到報錯:
This command failed to be executed because an error occurred while trying to get the file code from Spyder's editor. The error was: An exception has occurred, use %tb to see the full traceback. UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 582: illegal multibyte sequence UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 611: illegal multibyte sequence In [2]: %tb Traceback (most recent call last): File "C:\Users\peter\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 401, in get_file_code return f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 582: illegal multibyte sequence
先嘗試重啟程序,也許報錯就解決了。
解決方法是根據報錯,修改文件C:\Users\peter\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py為:
def get_file_code(filename): """Retrive the content of a file.""" # Get code from spyder try: file_code = frontend_request().get_file_code(filename) except (CommError, TimeoutError): file_code = None if file_code is None: with open(filename, 'r',encoding='utf-8') as f:#增加 ,encoding='utf-8' return f.read() return file_code
如果不重啟程序,會報錯:
[autoreload of spydercustomize failed: Traceback (most recent call last): File "C:\Users\peter\Anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 245, in check superreload(m, reload, self.old_objects) File "C:\Users\peter\Anaconda3\lib\site-packages\IPython\extensions\autoreload.py", line 394, in superreload module = reload(module) File "C:\Users\peter\Anaconda3\lib\imp.py", line 314, in reload return importlib.reload(module) File "C:\Users\peter\Anaconda3\lib\importlib\__init__.py", line 168, in reload raise ModuleNotFoundError(f"spec not found for the module {name!r}", name=name) ModuleNotFoundError: spec not found for the module 'spydercustomize' ] This command failed to be executed because an error occurred while trying to get the file code from Spyder's editor. The error was: An exception has occurred, use %tb to see the full traceback. UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 582: illegal multibyte sequence
關于anaconda spyder出錯怎么辦就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。