Open UncleBob125 opened 1 year ago
I had the same problem. Try it "sudo apt install python3-opencv"
I had the same problem. Try it "sudo apt install python3-opencv"
Hi billni, thanks for your answer.
I've tried that as well, but that installs it globally and not in my virtual environment. I need it to be in my virtual environment, since I want to package the application with all dependencies into single binary from that virtual environment.
It looks like I was able to reproduce the issue with my Pi 3b. Will take a look if I can propose some workaround before the next release.
It looks like I was able to reproduce the issue with my Pi 3b. Will take a look if I can propose some workaround before the next release.
Cheers, much looking forward to this
config-XXX.py is named differently depending on LIMITED_API option. https://github.com/opencv/opencv/blob/4.x/modules/python/common.cmake#L210
CI build enabled LIMITED_API
by default and it works well.
You can add -DPYTHON3_LIMITED_API=ON
to CMake options to work around the issue.
See https://github.com/opencv/opencv-python/blob/4.x/setup.py#L179 and https://github.com/opencv/opencv-python/blob/4.x/setup.py#L251
config-XXX.py is named differently depending on LIMITED_API option. https://github.com/opencv/opencv/blob/4.x/modules/python/common.cmake#L210 CI build enabled
LIMITED_API
by default and it works well. You can add-DPYTHON3_LIMITED_API=ON
to CMake options to work around the issue. See https://github.com/opencv/opencv-python/blob/4.x/setup.py#L179 and https://github.com/opencv/opencv-python/blob/4.x/setup.py#L251
Thank you very much. So its simply pip3 install opencv-python -DPYTHON3_LIMITED_API=ON --verbose
Or is that completely wrong?
Use environment variable CMAKE_ARGS
to define extra CMake arguments.
Fixed in #820
Its still coming up with the error?
I can see your little eyes looking! When you said fixed I presumed I would just run the install again and it should work?! A little more help is needed please, Alexander @asmorkalov :) I have spent weeks trying to get OpenCV working and every guide I have tried has failed! I don't see how it's so bloody hard to install?!
All I'm looking to do is run the NDVI script using my RPI 3B+ and NOIR V3 camera! I don't know if it helps but I could instal OpenCV on my Unraid server and have the feed from the Pi go there and the server does all the hard work. At the end of the day, my server is running Home Assistant in a VM but I need the Pi's NOIR camera with the blue filter over the lens.
Obviously, the new version that would include the bug fix hasn't been released to the Python package index since the fix was just merged into this repository. You'll have to wait for a new release, or clone this repository and do a manual build.
PHmm, I think I can clone this one and do it. Numpy, picamera and flask is already installed so will try cloning this and installing…Kind regards,JamieOn 17 Mar 2023, at 14:26, Olli-Pekka Heinisuo @.***> wrote: Obviously, the new version that would include the bug fix hasn't been released to the Python package index since the fix was just merged into this repository. You'll have to wait for a new release, or clone this repository and do a manual build.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Thanks for the fix @asmorkalov ! Is it correct this should now be available in the opencv-python-rolling deployment package? I tried to install this by using "pip install opencv-python-rolling==4.7.0.20230318" But it seems te version can't be found. On piwheels.org it says the build is skipped? => https://piwheels.org/project/opencv-python-rolling/ Should I take a different approach? Sorry if this is a dumb question, i'm pretty new to this.
Thanks in advance!
Rolling releases are broken for today. I'm working on it right now. I'll let you know, when you can try.
Rolling releases are broken for today. I'm working on it right now. I'll let you know, when you can try.
Any update? @asmorkalov Cheers
I had no luck with #820, but pinning the scikit-build version in pyproject.toml
to 0.17.1 everything worked again (without this 0.17.3 is installed):
--- "scikit-build>=0.13.2",
+++ "scikit-build==0.17.1",
I tested 0.17.2 and it fails with
AttributeError: 'NoneType' object has no attribute 'replace'
This was fixed in 0.17.3, but there seems to be some other change in there that's breaking things. Is there any reason to not pin this version for the builds?
This build failure is still present with python3.11. It appears to be caused by #835 — the incompatible numpy version apparently disables the python bindings since I can see that "install path" is omitted from the cmake version string no matter the value of -DCMAKE_PYTHON3_INSTALL_PATH. Updating numpy to a compatible version allowed me to build a wheel with 3.11. CI doesn't have this issue because of the TEST_DEP_LATEST override.
Should be fixed by #839.
The issue closed. OpenCV-Python 4.8.0 with the issue fix will be release in a couple of days.
@asmorkalov
I tried to build opencv-python package
into docker and got same error. How can I handle it?
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install --no-install-recommends -y build-essential gcc software-properties-common curl && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get install --no-install-recommends -y python3.10 python3.10-dev python3-pip python3-setuptools python3.10-distutils python3.10-venv
WORKDIR /venv
RUN python3.10 -m venv /venv
ENV PATH="/venv/bin:$PATH"
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
RUN pip3.10 install --upgrade pip
RUN python3.10 -m pip install --upgrade wheel setuptools requests
ENV OPENCV_VERSION=4.8.1
RUN apt-get install -y \
cmake \
libjack-jackd2-dev \
libmp3lame-dev \
libopencore-amrnb-dev \
libopencore-amrwb-dev \
libsdl1.2-dev \
libtheora-dev \
libva-dev \
libvdpau-dev \
libvorbis-dev \
libx11-dev \
libxfixes-dev \
libxvidcore-dev \
texi2html \
zlib1g-dev \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libavformat-dev \
libpq-dev \
x264 \
libx264-dev \
ffmpeg \
git
WORKDIR /opencv
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
unzip ${OPENCV_VERSION}.zip && \
mkdir opencv-${OPENCV_VERSION}/build
WORKDIR /opencv/opencv-${OPENCV_VERSION}/build
RUN cmake \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_TESTS=OFF \
-D BUILD_PERF_TESTS=OFF \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D PYTHON_EXECUTABLE=/usr/bin/python3.10 \
-D OPENCV_PYTHON3_INSTALL_PATH=/venv/lib/python3.10/site-packages \
-D BUILD_opencv_java=OFF \
-D WITH_CUDA=OFF \
-D WITH_CUDNN=OFF \
-D WITH_OPENCL=OFF \
-D WITH_OPENMP=OFF \
-D WITH_TBB=OFF \
-D WITH_IPP=OFF \
-D WITH_1394=OFF \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=OFF \
-D WITH_GSTREAMER_0_10=OFF \
-D WITH_GTK=OFF \
-D WITH_JASPER=OFF \
-D WITH_JPEG=ON \
-D WITH_OPENEXR=OFF \
-D WITH_PNG=ON \
-D WITH_TIFF=ON \
-D WITH_WEBP=OFF \
-D WITH_V4L=OFF \
-D WITH_VTK=OFF \
-D WITH_EIGEN=OFF \
-D WITH_PROTOBUF=OFF \
-D WITH_GDCM=OFF \
-D WITH_OPENJPEG=OFF \
-D WITH_OPENNI=OFF \
-D WITH_OPENNI2=OFF \
-D WITH_PVAPI=OFF \
-D WITH_ARAVIS=OFF \
-D WITH_GIGEAPI=OFF \
-D WITH_QT=OFF \
-D WITH_OPENGL=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D HAVE_opencv_python3=ON \
-D BUILD_opencv_gapi=ON \
-D PYTHON3_LIMITED_API=ON \
.. \
&& make -j$(nproc) \
&& make install
WORKDIR /opencv
RUN git clone https://github.com/opencv/opencv-python.git
WORKDIR /opencv/opencv-python
RUN python3.10 -m pip install scikit-build
RUN python3.10 setup.py bdist_wheel
Build output:
Copying files from CMake output
Traceback (most recent call last):
File "/opencv/opencv-python/setup.py", line 535, in <module>
main()
File "/opencv/opencv-python/setup.py", line 267, in main
skbuild.setup(
File "/venv/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
_classify_installed_files(
File "/opencv/opencv-python/setup.py", line 409, in _classify_installed_files_override
with open(config_py, 'w') as opencv_init_config:
FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-x86_64-3.10/cmake-install/python/cv2/config-3.py'
I had the same problem. Try it "sudo apt install python3-opencv"
This worked for me
"sudo apt install python3-opencv"
It's bad idea. The command installs yet another OpenCV-Python instance of some old version provided by Linux distribution. Doing that you get a salad of several instances of OpenCV that is loaded in inpredictable order. You can switch to distro-provided OpenCV Python, but all other instanced should be removed first.
sudo apt install python3-opencv
Anyway that didn't help
sudo apt install python3-opencv
Anyway that didn't help
How did you solve your problem? I encountered similar issue on RPi 4B
FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-aarch64-3.9/cmake-install/python/cv2/config-3.py'
error: subprocess-exited-with-error
× Building wheel for opencv-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /usr/bin/python3 /home/pbs/.local/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmp8g9__46_
cwd: /tmp/pip-install-vlokyin2/opencv-python_82696fa637964183835fb00d04c812e9
Building wheel for opencv-python (pyproject.toml) ... error
ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects
Probably, I installed numpy before running setup.py. Also here you can check my working Dockerfile for building wheel
Probably, I installed numpy before running setup.py. Also here you can check my working Dockerfile for building wheel
Thank you for your reply! The Dockerfile looks not much different from https://github.com/opencv/opencv-python/issues/814#issuecomment-1763476069
Did you find the reason of this error message?
Traceback (most recent call last):
File "/opencv/opencv-python/setup.py", line 535, in <module>
main()
File "/opencv/opencv-python/setup.py", line 267, in main
skbuild.setup(
File "/venv/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 706, in setup
_classify_installed_files(
File "/opencv/opencv-python/setup.py", line 409, in _classify_installed_files_override
with open(config_py, 'w') as opencv_init_config:
FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-x86_64-3.10/cmake-install/python/cv2/config-3.py'
Ah I see. you said installing numpy before running setup.py
Have I missed it, it there a solution to this problem? All I am wanting is to install DVR-Scan on a headless Pi.
Have I missed it, it there a solution to this problem? All I am wanting is to install DVR-Scan on a headless Pi.
I resolved the issue with building opencv-python source manually. (latest release one)
ChanJoon, thank you for your suggestion. Rather than go down the rabbit hole of a manual installation I searched for "installing opencv rpi" and found the following comment:
The standard command to install opencv is pip install opencv-contrib-python but don’t immediately run this (!) as it will try to install the latest versio of OpenCV, which is not always fully functional on the Raspberry Pi. Furthermore, the installation may take a very long time. Therefore I recommend to run the below command that installs the latest known working version. Here I use 4.5.3.56 but it could be that already a newer stable version is available
Using instructions on this site:
https://singleboardblog.com/install-python-opencv-on-raspberry-pi/
and after installing the prerequisites I used this command:
pip install opencv-python-headless==4.5.3.56
This installed opencv very quickly, but obviously for an earlier version.
I know that this thread is not about DVR-Scan but to install it I then used:
pip install dvr-scan[opencv-headless]
Progress at least.
We had this issue recently and found it was due to cmake not creating the opencv python library cv2.abi3.so
. Check back on the build logs from cmake and look at the lines that say:
-- OpenCV modules:
-- To be built:
make sure that python3
is in this list (as it likely isn't). Further up in the logs I could then see the following error:
-- Found PythonInterp: /venv/bin/python3.10 (found suitable version "3.10.13", minimum required is "3.2")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so (found suitable exact version "3.10.13")
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
For me the fix was just to install numpy first. Change the Dockerfile in https://github.com/opencv/opencv-python/issues/814#issuecomment-1763476069 to install it before build:
- RUN python3.10 -m pip install scikit-build
+ RUN python3.10 -m pip install scikit-build numpy
Was this supposed to be fixed? I'm still getting the exact same fail signature as in the subject line with opencv-python-headless 4.9 and 4.8 and Raspbian Bullseye.
consider installing python3-dev or python3-devel using yum it worked for me with opencv-python-headless when it cant build wheel
Hrm, nope.
dpkg --list | grep python3-dev ii libpython3-dev:armhf 3.9.2-3 armhf header files and a static library for Python (default) ii python3-dev 3.9.2-3 armhf header files and a static library for Python (default)
6 hours later...
File "setup.py", line 411, in _classify_installed_files_override with open(config_py, 'w') as opencv_init_config: FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-armv7l-3.9/cmake-install/python/cv2/config-3.py'
Pretty much always the same thing; this was with 4.9.0.80.
I also have the same error. I am trying to install it on raspberry pi 3
Having the same error while build armv7 with docker python:3.11.5-bookworm
I did try running with: CMAKE_ARGS=-DPYTHON3_LIMITED_API=ON pip install opencv-python-headless --verbose
without success
Same problem building it in a docker buildx crosscompiling to arm/v7 and compiling in a raspberry directly.
Has anyone managed to get this working? I'm having the same issue on my raspberry pi
Have the same problem on raspberry pi 5
try this.
pip install numpy==1.23.5
I was able to install OpenCV on a RaspberryPi 3B+ on Bullseye using the process described here: https://www.orionrobots.co.uk/2024/02/20/installing-opencv-and-numpy-learnrobotics.html
Expected behaviour
I tried to install opencv-python in my virtual environment and was expecting the opencv-python library v4.7.0.72 to be installed succesfully. Even after multiple tries and trying different solutions/workarounds found online, nothing seems to help.
Actual behaviour
The build runs for +-3 hours, goes to 100% and then later on fails during installation phase of the project. Following error is being returned: FileNotFoundError: [Errno 2] No such file or directory: '_skbuild/linux-armv7l-3.9/cmake-install/python/cv2/config-3.py' error: subprocess-exited-with-error
Steps to reproduce
result
``` (venv) username@raspberrypi:~/Desktop/myApp $ pip3 install --upgrade pip Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: pip in ./venv/lib/python3.9/site-packages (23.0.1) ```result
System
What I've tried so far