AttributeError: module 'cv2' has no attribute 'face
时间: 2023-10-01 19:12:02 浏览: 56
在使用OpenCV中的人脸识别模块时,出现"AttributeError: module 'cv2' has no attribute 'face'"错误的原因是没有正确安装需要的依赖模块。
解决该问题的方法是安装OpenCV的contrib版本,其中包含了人脸识别相关的模块。你可以通过执行"pip install opencv-contrib-python"命令来安装该模块。请确保你已经卸载了之前的错误安装并重新指定了正确的版本。重新启动你的pycharm后,你应该能够成功导入cv2模块,并且使用"cv2.face"模块进行人脸识别。
总结一下解决步骤:
1. 卸载之前错误安装的OpenCV模块。
2. 重新指定正确的OpenCV版本,执行"pip3 install opencv-python==4.5.5.62"命令进行安装。
3. 安装包含人脸识别模块的contrib版本,执行"pip install opencv-contrib-python"命令进行安装。
4. 重新启动你的pycharm,并尝试运行你的代码,应该不再出现"AttributeError: module 'cv2' has no attribute 'face'"错误了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [【AttributeError: module cv2.face has no attribute face解决方法】](https://blog.csdn.net/qq_63188936/article/details/126044244)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]