问题描述
学数据挖掘时,安装新的Python环境后,使用pip去安装其他的python包报错问题
报错内容描述:
Non-zero exit code (2)
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:\hww\hm_learning\py3.8\Scripts\python.exe’.
解决方案:
查看了许多个博客,依旧没有解决,最终发现是pip版本不兼容,导致安装失败,需要去回退一下pip版本,我之前使用的是 23.2.1,pip版本过高。
然后我查看了python版本对应pip版本:
python3.8对应的pip版本是pip 19.2.3及更高版本。
但是pip 20.0.2版本是比较稳定的,因此之后选择了它。
步骤:
1.使用这段代码去回退pip的版本:
python -m pip install pip==20.0.2
输入之后就会开始运行: 2. 然后查看降级后的版本:
pip -V
3.然后就可以使用pip安装代码
python -m pip install 模块名
python -m pip install matplotlib # 例子,我需要安装的包
python -m pip install numpy# 例子,我需要安装的包
4.最后大功告成
也可以不用命令行直接去pycharm里面安装:
步骤:
1.打开设置
2.点击这里
3.自行搜索即可
python下载包的网址(whl):
https://pypi.org/
https://www.lfd.uci.edu/~gohlke/pythonlibs/