'Python opencv Aruco "No module named 'cv2.aruco'"
I am running an Ubuntu virtual machine with, Python 3.6.1, Anaconda 4.4.0 (64-bit). I am trying to run the code on this website. When I try to use
import cv2.aruco
I get:
>>> import cv2.aruco
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2.aruco'
Is this something I need to install or setup?
Solution 1:[1]
If cv2.aruco
is not found, try installing opencv-contrib-python
, such as by running the following (for the default Python installation):
pip install opencv-contrib-python
Or for a specific Python installation (in this case Python 3)
python3 -m pip install opencv-contrib-python
Then try re-running the script trying to access cv2.aruco
.
Solution 2:[2]
If cv2.aruco
is not found, first make sure that opencv-python
is not installed.
for that you can use:
pip uninstall opencv-python
Then install:
pip install opencv-contrib-python
We are uninstalling opencv-python because installing two packages of opencv will contradict each other and will not let the other one install.
Solution 3:[3]
In my case both opencv-python
and opencv-contrib-python
were installed when I was getting the above error.
So I uninstalled opencv-python using
pip uninstall opencv-python
Run the program and same error. Then I uninstalled opencv-contrib-python
pip uninstall opencv-contrib-python
After that I reinstalled opencv-contrib-python using
pip install opencv-contrib-python
And run the program, no error now. So I upvoted both the above answers :)
Solution 4:[4]
In case you still need opencv-python for other applications, do the following (in this order, using pip or pip3):
pip3 uninstall opencv-python
pip3 uninstall opencv-contrib-python
pip3 install opencv-python
pip3 install opencv-contrib-python
If you reverse the last two operations, you will still have the error message.
Solution 5:[5]
This will fix this issue
pip uninstall python-opencv
pip install --upgrade opencv-contrib-python==3.4.2.17
Other answers do not mention versions, that's why they won't be able to fix this issue. cv2.aruco is no longer present in newer versions
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | intcreator |
Solution 2 | SaKu. |
Solution 3 | Mian Asbat Ahmad |
Solution 4 | Rexcirus |
Solution 5 | Priyanshu Dwivedi |