yolov5依赖库安装

        上一篇文章中已经在Anaconda中建立了一个pytorch的虚拟环境,在这个环境中安装yolov5的依赖库。(其实应该新建一个虚拟环境,在这个里面安装依赖库)

进入Anaconda Prompt,激活pytorch虚拟环境

requirements.txt放在C盘用户文件夹下

否则会提示找不到文件

输入下面的安装命令

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed

安装结束出显示安装了那些包

这样就将yolov5所需的依赖库安装在了Anaconda中创建的虚拟环境中了。

        ps:用国内源安装速度挺快的,不要自己下载.whl文件安装,不然各个包的版本之间可能会出现很多问题。

安装过程中遇到的问题

用上面的方法安装应该不会遇到什么问题,记录一下自己安装环境过程中走的弯路。

1 最初安装环境的时候是在pycharm中打开Terminal,直接输入pip install -r requirements.txt 进行安装,这样做的问题主要有:

1)依赖库不是安装在虚拟环境中,因此安装之后运行yolov5也会报错,要求安装所需的以来库,因为python是安装在虚拟环境中的;

2)此时使用的是国外的网站,网速很慢,很容易断。

 

 2 因为前期需要依赖库是自己下载.whl文件手动安装的,出现很多问题,比如:

 twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
cryptography 3.3.2 requires cffi>=1.12, which is not installed.
conda 4.13.0 requires ruamel_yaml_conda>=0.11.14, which is not installed.

这个问题是说twisted 18.7.0 等需要的库没有安装,可以用pip安装(此时不需要添加国内源链接)

pip install PyHamcrest>=1.9.0

pip install cffi>=1.12

但是安装ruamel_yaml_conda>=0.11.14时用pip安装会报错(并没有解决)

 

 也可能出现下面的问题

cryptography 3.3.2 requires cffi>=1.12, but you have cffi 1.11.5 which is incompatible.

 pip uninstall cffi 1.11.5

cffi需要写版本号

3 卸载yolov5依赖库

可以使用命令  pip uninstall -r requirements.txt

ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and ..

 网上推荐的方法--upgrade不太管用,最后用

 pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --ignore-installed

 但也有问题,最后用本文最上面的方法解决了

5 error: Microsoft Visual C++ 14.0 is required

 根据给出的网页链接下载vs_BuildTools.exe安装包,安装【桌面应用与移动应用】中的“使用C++的桌面开发”即可