解決python 出現unknown encoding: idna 的問題

這個問題是編碼的問題在開頭導入個包就行瞭,簡答粗暴

import encodings.idna

補充:執行Python出現LookupError: unknown encoding: cp65001解決辦法

在執行fetch v8時出現

E:\GitProject\svn_v8>fetch v8
Running: ‘E:\GitProject\libcef\depot_tools\python276_bin\python.exe’ ‘E:\GitProj
ect\libcef\depot_tools\gclient.py’ root
Traceback (most recent call last):
File “E:\GitProject\libcef\depot_tools\\fetch.py”, line 353, in <module>
sys.exit(main())
File “E:\GitProject\libcef\depot_tools\\fetch.py”, line 348, in main
return run(options, spec, root)
File “E:\GitProject\libcef\depot_tools\\fetch.py”, line 342, in run
return checkout.init()
File “E:\GitProject\libcef\depot_tools\\fetch.py”, line 134, in init
self.run_gclient(‘config’, ‘–spec’, self._format_spec())
File “E:\GitProject\libcef\depot_tools\\fetch.py”, line 76, in run_gclient
return self.run(cmd_prefix + cmd, **kwargs)
File “E:\GitProject\libcef\depot_tools\\fetch.py”, line 63, in run
print ‘Running: %s’ % (‘ ‘.join(pipes.quote(x) for x in cmd))
LookupError: unknown encoding: cp65001

LookupError: unknown encoding: cp65001

出現此錯誤後改變編碼方式即可解決:

chcp 1252

也可以通過修改註冊表CodePage值來設置默認字符編碼

HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe\CodePage

以上為個人經驗,希望能給大傢一個參考,也希望大傢多多支持WalkonNet。如有錯誤或未考慮完全的地方,望不吝賜教。

推薦閱讀: