pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python...

安裝ddt遇到的坑:

1.在cmd用pip install ddt 安裝ddt的時候報錯
Could not find a version that satisfies the requirement ddt (from versions: )
No matching distribution found for ddt
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第1张图片
方法一:更新pip版本為最新版10.0.1,問題沒解決
方法二:这是因为网络的问题,需要使用国内的镜像源来加速,比如豆瓣源(若以下方法沒解決請繼續百度其他鏡像源頂上)

pip install ddt命令改为:

pip install ddt -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第2张图片出現successfully installed 即安裝成功;

2.pycharm,從settings安裝ddt的時候會顯示安裝失敗,如下:
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第3张图片
原因是:Try to run this command from the system terminal. Make sure that you use the correct version of ‘pip’ installed for your Python interpreter located at ‘D:\PycharmProjects\httptest\venv\Scripts\python.exe’.
上百度翻譯:尝试从系统终端运行此命令。请确保为位于“d:\pycharmprojects\httptest\venv\scripts\python.exe”的python解释器安装了正确版本的“pip”。

看到“D盤的python解釋器”我就懵了…啥玩意python解釋器我200%確定安裝在C盤了!再看當前項目解釋器用的是虛擬環境路徑,如下圖:
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第4张图片
然後觀察這兩解釋器安裝ddt是有區別的:
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第5张图片
嘗試著選擇python安裝路徑安裝ddt,成功了!
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第6张图片
再選擇虛擬環境安裝ddt,還是報錯
再選擇其他項目的虛擬環境安裝ddt,又報錯…可是安裝requests是可以的啊,難道成不成功還看心情的?
陷入自閉…算了,先留個懸念待解決
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python..._第7张图片
為了今後能夠順利導入庫,創建項目的時候直接選擇python安裝的路徑作為解釋器即可!
具體操作可參考:
https://blog.csdn.net/qq_33485434/article/details/82462407

你可能感兴趣的:(python)