I’m experiencing the issue of python3.6.9 not working with Adafruit circuitpython servokit. I upgraded to python3.7 and got the servokit to work but the openCV would not. I’ve attempted to install older versions of the servokit but it won’t work with python3.6.9. I’m now wondering if I should try using python3.7 and installing a different version of openCV. Any help would be appreciated. I’ve spent days trying to get this to work.
Hi,
You can try to build an OpenCV from the source for Python 3.7.
Below is a script for your reference.
Please update the default Python 3.6-related command into Python 3.7 based on your requirements.
Thanks.
Hi, thanks, I’ve made python3.7.5 the default. I ran the script and replaced python3.6 with python3.7. It made a directory called ‘workspace’. Took over 2 hours to run through it. When I try to install it so that I can use it, I get the error message: Could not find a version that satisfies the requirement opencv (from versions: ) No matching distribution for opencv ~ScottAA55
Hi,
The installation should be done by running sudo make install
.
You don’t need to run the pip3
command after that.
If OpenCV cannot be found after installation, please try the below command to see if it works.
$ export PYTHONPATH=/usr/local/lib/python[ver]/site-packages/:$PYTHONPATH
Thanks.
Tried that. Result: "No module named ‘cv2’
Hi,
Could you share the output of the below command with us?
$ sudo find / -iname cv2.cpython-*
Thanks.
find: ‘/run/user/1000/gvfs’: Permission denied
tried it with 2> /dev/null at the end
It worked for a few seconds and came back to the prompt with nothing.
I then went to home directory and typed the following:
sudo apt-get install python3-opencv
When I opened python3 and tried import cv2, I got the message:
ModuleNotFoundError: No module named cv2
I then ran python (python2.7.17) tried import cv2 and it worked.
Conclusion: opencv4.5.0 did not install in python3.7.5
The process took several hours. This time I started with freshly flashed card from scratch.
Hi,
The script does enable Python3 support:
cmake ... -D BUILD_opencv_python3=ON
Do you see python3 listed in the cmake summary?
For example:
-- General configuration for OpenCV 4.5.0 =====================================
-- Version control: unknown
...
-- Python 2:
-- Interpreter: /usr/bin/python2.7 (ver 2.7.18)
-- Libraries: NO
-- numpy: NO (Python wrappers can not be generated)
-- install path: -
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.8.10)
-- Libraries: /usr/lib/aarch64-linux-gnu/libpython3.8.so (ver 3.8.10)
-- numpy: /usr/local/lib/python3.8/dist-packages/numpy/core/include (ver 1.22.0)
-- install path: lib/python3.8/site-packages/cv2/python-3.8
...
Thanks.
The install python3-opencv reverts back to the default state. Probably not what you want to do.
Among the issues is that you have to tell Python 3.7.5 where you placed the newly built version of OpenCV. Did you actually check your PYTHONPATH to see if it points to the correct location, and that the modules exist there? What was the exact PYTHONPATH you created?
Here’s a video on you might go about setting up your environment. The first part of the video builds the OpenCV version (you can skip this is you preferred the version stated here), and then determines where the newly placed version is, then sets the PYTHONPATH accordingly:
Please keep topic open as I’m still working on it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.