AttributeError: module 'cv2' has no attribute 'show'
时间: 2023-09-29 12:06:59 浏览: 354
Python在Geany中调用matplotlib绘图时出现attributeerror错误
根据引用中的错误信息,"AttributeError: module 'cv2' has no attribute 'show'",这个错误表明在cv2模块中没有名为'show'的属性。通常情况下,cv2模块提供了'show'函数来显示图像,但是在这个特定的环境中,这个函数可能不存在。
解决这个问题的方法是尝试安装不同版本的opencv-contrib-python-headless。根据引用中的建议,可以尝试安装版本为4.2.0.32的opencv-contrib-python-headless。可以使用以下命令来安装:
pip install opencv-contrib-python-headless==4.2.0.32
另外,还需要确保之前安装的opencv相关包已经被清除干净。你可以卸载之前的opencv相关包,然后再安装opencv-contrib-python-headless。
总结一下,解决"AttributeError: module 'cv2' has no attribute 'show'"的方法是:
1. 尝试安装不同版本的opencv-contrib-python-headless,例如4.2.0.32。
2. 确保之前安装的opencv相关包已经被清除干净。
3. 安装完新的opencv-contrib-python-headless后,重新运行代码,看是否能够解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [【解决方法】AttributeError: module ‘cv2‘ has no attribute ‘INTER_NEAREST](https://blog.csdn.net/qq_35129353/article/details/125273931)[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: 33.333333333333336%"]
- *2* [求解报错:AttributeError:module ‘os’ has no attribute ‘exit’](https://download.csdn.net/download/weixin_38590309/14856609)[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: 33.333333333333336%"]
- *3* [AttributeError: module ‘cv2‘ has no attribute ‘xfeatures2d](https://blog.csdn.net/weixin_40809724/article/details/127265000)[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: 33.333333333333336%"]
[ .reference_list ]
阅读全文