1.python安裝ldap出現gbk無法解碼的錯誤:
- 2.安裝python-ldap出現缺失檔案錯誤,具體如下
- 3.項目是Python2文法 python3環境運作不了
- 4.anaconda中沒有ldap包 需要手動加入 同1方法将包手動加入到envs/python2/Lib中
- 5.錯誤顯示key值不能為空
1.python安裝ldap出現gbk無法解碼的錯誤:
原因:win10編碼問題:
解決:在D:\pycharm\python\Lib\site-packages下建立sitecustomize.py
檔案内容為:
import _locale
_locale._getdefaultlocale = (lambda *args: ['zh_CN', 'utf8'])
2.安裝python-ldap出現缺失檔案錯誤,具體如下
c:\users\mengchuanli001\appdata\local\temp\pip-install-89ik7t4f\python-ldap\modules\constants.h(7): fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
解決方式:采用whl檔案進行安裝
1.檢查本機python支援版本号:在cmd——》python——》輸入
AMD64
import pip._internal
print(pip._internal.pep425tags.get_supported())
1
2
WIN32
import pip
print(pip.pep425tags.get_supported())
2.在https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap中找到對應支援版本号的whl檔案進行下載下傳
3.在檔案安裝目錄下執行whl安裝指令如:
pip install pyldap-2.4.45-cp37-cp37m-win_amd64.whl
4。pip list檢查是否安裝完成
3.項目是Python2文法 python3環境運作不了
打開anaconda增加Python2環境,将anaconda中的python.exe增加到python環境設定中
4.anaconda中沒有ldap包 需要手動加入 同1方法将包手動加入到envs/python2/Lib中
這裡注意在anaconda虛拟環境下進行安裝在,軟體裡的該環境下面打開終端,再用1的方式安裝ldap
注意:python-ldap版本>=3.0
安裝完之後要安裝
pip install django
-
auth
-
ldap
5.錯誤顯示key值不能為空
但是settings.py中的key值不為空,說明項目中的django配置沒有被加載調試發現,預設配置為djangofirst 而不是djangofirst.settings
參考部落格:https://blog.csdn.net/qq_33733970/article/details/80503022
https://blog.csdn.net/weixin_38917807/article/details/81675948