安裝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...
方法一:更新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...出現successfully installed 即安裝成功;

2.pycharm,從settings安裝ddt的時候會顯示安裝失敗,如下:
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python...
原因是: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...
然後觀察這兩解釋器安裝ddt是有區別的:
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python...
嘗試著選擇python安裝路徑安裝ddt,成功了!
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python...
再選擇虛擬環境安裝ddt,還是報錯
再選擇其他項目的虛擬環境安裝ddt,又報錯…可是安裝requests是可以的啊,難道成不成功還看心情的?
陷入自閉…算了,先留個懸念待解決
pycharm安裝庫出現Make sure that you use the correct version of 'pip' installed for your Python...
為了今後能夠順利導入庫,創建項目的時候直接選擇python安裝的路徑作為解釋器即可!
具體操作可參考:
https://blog.csdn.net/qq_33485434/article/details/82462407

相关文章:

  • 2021-03-26
  • 2021-04-30
  • 2022-12-23
  • 2021-08-07
  • 2021-09-09
  • 2021-12-17
  • 2021-09-23
猜你喜欢
  • 2021-05-01
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案