使用 pip install -U -r requirements.txt 在pycharm的终端进行安装。
首先第一个报错:
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
出现这个报错的原因是当前目录下没有名为requirements.txt的文件,大概率是因为你没有进入存放该文件的上级目录。使用cd指令进入存放该文件的上级目录。以下是示例
cd PS C:\Users\你的PC用户名\Desktop\yolov5> cd C:\Users\你的PC用户名\Desktop\yolov5\yolov5-master
执行完后pycharm终端就会从 C:\Users\Phoenix\Desktop\yolov5>
切换为C:\Users\Phoenix\Desktop\yolov5\yolov5-master>
继续使用pip install -U -r requirements.txt 在pycharm的终端进行安装。
第二个报错:
ERROR: Cannot uninstall 'PyYAML'. 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.
错误:无法卸载“PyYAML”。这是一个distutils安装的项目,因此我们无法准确确定哪些文件属于它,这只会导致部分卸载。
在其他博客里找到的解决方法是:
pip install -U -r requirements.txt --ignore-installed PyYAML
加入 --ignore-installed PyYAML 忽略报错库的安装,但是在实际使用时却会遇到下一个报错。
第三个报错:
ERROR: Double requirement given: PyYAML>=5.3.1 (from -r requirements.txt (line 11)) (already in PyYAML, name='PyYAML')
错误:给出了双重要求:PyYAML>=5.3.1(来自-r requirements.txt(第11行))(已在PyYAML中,名称=“PyYAML”)
这里我找了好久也没找到解决办法,最后只好从报错入手,去查看了requirements.txt文件,将其中的
PyYAML>=5.3.1
替换为(相当于忽略版本要求)
PyYAML
重新执行 pip install -U -r requirements.txt --ignore-installed PyYAML 但又会出现好多报错。
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.
spyder 4.1.5 requires pyqt5<5.13; python_version >= "3", which is not installed.
spyder 4.1.5 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
torchaudio 2.2.1+cu118 requires torch==2.2.1+cu118, but you'll have torch 2.2.1 which is incompatible.
我们一个个来解决,先从
spyder 4.1.5 requires pyqt5<5.13; python_version >= "3", which is not installed.
spyder 4.1.5 requires pyqtwebengine<5.13; python_version >= "3", which is not installed.
着手,原因是Spyder不是最新版本,而我的pyqtwebengine和pyqt5的版本是最新的,出现了不匹配的问题,需要安装新版本的Spyder。使用指令
pip install spyder==*
可以查看所有版本的spyder
我这里下载的是5.5.1版本
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ spyder==5.5.1
类似的报错都可以通过如上的方式处理。