python報(bào)錯(cuò)
(tf-gpu) C:\Users\dell>pythonPython 3.6.2 |Anaconda, Inc.| (default, Sep 30 2017, 11:52:29) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.Failed calling sys.__interactivehook__Traceback (most recent call last): File "D:\Users\dell\Anaconda3\envs\tf-gpu\lib\site.py", line 410, in register_readline readline.read_history_file(history) File "D:\Users\dell\Anaconda3\envs\tf-gpu\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file self.mode._history.read_history_file(filename) File "D:\Users\dell\Anaconda3\envs\tf-gpu\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file for line in open(filename, 'r'):UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 356: illegal multibyte sequence>>>
https://tieba.baidu.com/p/6126998933
實(shí)際上不影響使用,不過(guò)覺(jué)得不爽姻锁,網(wǎng)上由些解答是刪除pyreadline枕赵。實(shí)際問(wèn)題是讀某個(gè)文件,其中包含了gbk編碼位隶,也就是中文拷窜,這里沒(méi)辦法解析〗Щ疲可能是pyreadline支持不夠好篮昧,所以產(chǎn)生這個(gè)問(wèn)題。
進(jìn)一步查找笋妥,我這里的問(wèn)題是開(kāi)始時(shí)讀pythonhistory文件懊昨,在c:\user\username\下,這個(gè)文件中包含了中文春宣,你只要?jiǎng)h除這個(gè)歷史文件就好了酵颁。大部分情況是你的程序目錄包含中文的原因嫉你。
————————————————
版權(quán)聲明:本文為CSDN博主「fjnuzs」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議躏惋,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明幽污。
原文鏈接:https://blog.csdn.net/fjnuzs/article/details/99850229