im使用python 3,但需要安装python 2进行测试。卸载python2后,如果我运行python 3代码,则会出现以下错误:
$( "#combobox" ).combobox({
select: function(event, ui) {
console.log("Selected");
// Event handling code goes here.
} // selected
});
这是我的代码:
Failed to import the site module
Traceback (most recent call last):
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 570, in <module>
main()
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 557, in main
known_paths = addsitepackages(known_paths)
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 159, in addpackage
f = open(fullname, "r")
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\_bootlocale.py", line 12, in getpreferredencoding
if sys.flags.utf8_mode:
AttributeError: 'sys.flags' object has no attribute 'utf8_mode'
Failed to import the site module
Traceback (most recent call last):
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 570, in <module>
main()
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 557, in main
known_paths = addsitepackages(known_paths)
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\site.py", line 159, in addpackage
f = open(fullname, "r")
File "C:\Users\2325\AppData\Local\Programs\Python\Python37\lib\_bootlocale.py", line 12, in getpreferredencoding
if sys.flags.utf8_mode:
AttributeError: 'sys.flags' object has no attribute 'utf8_mode'
如您所见,没有任何东西会使此错误出现。 如果我运行一个简单的hello world程序,一切正常。
答案 0 :(得分:0)
我真的不知道为什么,但是,在sys.flags中没有名为utf8_mode的属性。如果要查看和比较编码,请尝试:
> vue.esm.js:1741 ReferenceError: body is not defined
> at o.eval (eval at ko (vue.esm.js:10680), <anonymous>:3:642)
> at o.t._render (vue.esm.js:4544)
> at o.<anonymous> (vue.esm.js:2788)
> at je.get (vue.esm.js:3142)
> at new je (vue.esm.js:3131)
> at vue.esm.js:2795
> at o.hn.$mount (vue.esm.js:8540)
> at o.hn.$mount (vue.esm.js:10939)
> at init (vue.esm.js:4137)
> at vue.esm.js:5608
或者也许:
if sys.getdefaultencoding() == 'utf-8':
continue
我不确定自己在做什么,因为没有代码,所以这是我所能做的限制。
编辑: 错误似乎出在python的lib文件夹内的_bootlocale.py文件上。我认为从python 2.x来的一些残余被遗留下来,并且在返回到3.x之后没有被覆盖或更新
我认为先卸载再删除整个python文件夹,然后检查local_variables以防万一,在重新安装python 3.x之前可以解决此问题,尽管我不确定是否会解决。