python项目:
项目场景:从GitHub上下载了一个无监督红外-可见光行人重识别项目,其中运行配置遇到了很多问题,在此先记录一下。
问题描述
在项目debug时,提示此地方
from sklearn.cluster import DBSCAN
出现错误:
(<class 'ModuleNotFoundError'>, ModuleNotFoundError("No module named 'sklearn'"), <traceback object at 0x000001572961FF00>)
原因分析:
好像是有一些包没下载
在网上搜了一些命令:``
pip install --target=d:\developer_tools\anaconda3\lib\site-packages scikit-learn
出错1
之前下载不成功,这次下载好像成功下载了一些包,但是又出错了
原因分析
发现是版本不匹配问题,重新调整一下版本
C:\Users\Administrator>pip install daal4py>=2021.4
出错2
ERROR: Cannot uninstall ‘TBB’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
原因分析
发现是安装包重复
此方法试了一下,发现找不到.egg-info文件,无法手动删除。
-方法:在我的安装文件夹中D:\software\Anaconda3\Anaconda3\Lib\site-packages下,找到TBB.egg-info,手动删除后。再使用pip升级即可安装成功。不只是‘TBB’,安装包的时候报哪个错误,就删除对应名字.egg-info即可。
解决方案:
又找到另一种命令方法
C:\Users\Administrator>pip install --ignore-installed TBB
结果:
提示:遇到任何Cannot uninstall ‘xxx’ 问题时,都可以用下办法解决
pip install --ignore-installed [xxx]
继续调整安装numpy版本为1.18
C:\Users\Administrator>pip install numpy==1.18
出错3
又出错了,学习路线像个无底洞。
安装numpy==1.18版本时出现此错误
报错原因
看了一些文章分享,猜测可能是之前下载的numpy版本不兼容的问题。
输入 pip install numpy== 查看numpy的版本信息。输出:
出错4
准备下载一个高一点的版本numpy==1.22.0,又出错了,还是不匹配
解决方法
1.直接用conda虚拟环境安装sklearn试试:
激活虚拟环境
conda activate sklearn
2.在虚拟环境中安装包:建议按照次序安装包。
可以选择指定具体的版本,如:
conda install numpy
conda install pandas
conda install scipy
conda install matplotlib
conda install scikit-learn==0.20.0
安装完成后不报No module named 'sklearn
此错误了。
参考博客:https://blog.csdn.net/weixin_44753371/article/details/103902751