安裝pymongo的編碼問題

2021-06-26 01:01:38 字數 598 閱讀 4311

安裝好mongodb後安裝mongo-python驅動

在命令列輸入

easy_install pymongo

出現問題:unicodedecodeerror: 』ascii』 codec can』t decode byte 0xb0 in position 1: ordinal not in range(128)  

查閱相關資料,是python預設ascii編碼

解決辦法:在python安裝目錄下找到lib檔案下的mimetypes.py檔案,在第255前增加3行

[python]view plain

copy

ifsys.getdefaultencoding() != 

'gbk'

:  reload(sys)  

sys.setdefaultencoding('gbk'

)  default_encoding = sys.getdefaultencoding()  

參考

安裝pymongo報錯

1 直接在命令列使用pip install pymongo報錯 could not install packages due to an environmenterror errno 13 許可權不夠 usr local lib python2.7 dist packages pymongo 3.8...

pymongo問題集合

1.問題 使用sort排序,如下 db.test.find sort 不能使用字典 遇到如下異常 typeerror if no direction is specified,key or list must be an instance of list 解決方法 db.test.find sort...

django 安裝編碼問題

今天重灌了win10系統,需要重搭開發環境。但在重灌django包的時候出現了安裝錯誤 unicodedecodeerror ascii codec can t decode 懷疑是重灌系統時把使用者名稱設為中文名的緣故。於是在d python lib 下找到ntpath.py檔案 瘋狂列印,在下面...