1

解决pip install x ERROR: Could not install packages due to an OSError…问题

 4 months ago
source link: https://xushanxiang.com/pip-install-oserror.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

解决pip install x ERROR: Could not install packages due to an OSError…问题

作者: xusx 分类: Python 发布时间: 2024-01-11 21:24 浏览:13
python.jpg

在进行人脸数据训练时,执行Python文件,出现下面错误:

Traceback (most recent call last):
  File "D:/microPythonCode/camera/trainer.py", line 47, in <module>
    recognizer=cv2.face.LBPHFaceRecognizer_create()
AttributeError: module 'cv2.cv2' has no attribute 'face'

出现AttributeError: module “cv2” has no attribute “face”,就需要安装opencv-contrib-python库。

一般的安装方法如下:

pip install opencv-contrib-python
或者
pip install opencv-contrib-python -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

但是,下载150M左右的文件后,安装时出现的显眼的红色报错:

ERROR: Could not install packages due to an OSError: [Errno 2] No such file......

这个错误通常表示在尝试安装或升级包时,找不到特定的文件或目录。这可能是由于多种原因引起的,包括文件损坏、依赖关系问题或环境配置问题。

如果你遇到同样的问题,可以尝试我解决这个问题的方法

(1)opencv-contribopencv必须具有完全相同的版本。

>pip list
...
numpy                             1.19.5
opencv-python                     4.5.1.48
packaging                         21.3
pandas                            1.1.5
...
>pip install opencv-contrib-python==4.5.1.48
...
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.5.1.48
...

(2)如果仍然出现错误,请更改了它们的版本。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK