ModuleNotFoundError:尽管安装了但没有名为“cv2"的模块 [英] ModuleNotFoundError: No module named 'cv2' despite installation
问题描述
当我在 Python 中导入 cv2
时,我得到 p>
When I import cv2
in Python I get
ModuleNotFoundError: No module named 'cv2'
我用
pip3 install opencv-python
当我再次尝试安装时,它说
When I try to install it again, it says
Requirement already satisfied: opencv-python in /usr/local/lib/python3.7/dist-packages (4.0.1.24)
Requirement already satisfied: numpy>=1.14.5 in /usr/local/lib/python3.7/dist-packages (from opencv-python) (1.16.2)
我成功地再次检查了相应的 Python 文件夹中是否有可用的包.我什至为 Python2.7 安装了它,尽管 Python3.7 是我的标准.我从字面上通读了我可以在 Stackoverflow 上找到的所有关于错误的信息,现在我已经没有想法了.有什么想法吗?
I successfully double-checked if package is available in the appropriate Python folder. I even installed it for Python2.7 though Python3.7 is my standard. I literally read through all information I could find on Stackoverflow regarding the error and I am run out of ideas now. Any ideas?
我使用 Ubuntu 18.04 和 Python 3.7.
I use Ubuntu 18.04 and Python 3.7.
推荐答案
尝试使用操作系统的包管理器进行安装(注意词序:opencv
之前的python
):
Try installing with your OS's package manager (notice the word order: python
before opencv
):
sudo apt-get install python-opencv
这在 Ubuntu 18 上对我有用.我也无法使用 pip
让它工作.
This worked for me on Ubuntu 18. I also was unable to get it to work using pip
.
这篇关于ModuleNotFoundError:尽管安装了但没有名为“cv2"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!