Issues building from source on Ubuntu with Python 3.10.4
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 1k
- Avg merge
- 22h 17m
- Merged PRs (30d)
- 3
Description
Expected behaviour
I need to build opencv-python from source on Ubuntu 22.04 with Python 3.10.4. However, I would like to override the default PYTHON3_NUMPY_INCLUDE_DIRS setting from something like /home/user/miniconda3/envs/py310/lib/python3.10/site-packages/numpy/core/include to /home/user/miniconda3/envs/py310/lib/python3.10/site-packages/numpy/core/include/numpy. Is there any way to achieve this, because otherwise the build fails as I encounter the following error fatal error: numpy/ndarrayobject.h: No such file or directory.
Actual behaviour
Already described above.
Steps to reproduce
- example code
- Change directory to
opencv-python. - Enable virtual Python environment and make sure
numpyandscikit-buildare installed. - Set environment variables using the following:
- Change directory to
export CMAKE_ARGS="-DWITH_CUDA=ON \
-DWITH_CUDNN=ON \
-DOPENCV_DNN_CUDA=ON \
-DWITH_CUBLAS=ON \
-DPYTHON3_EXECUTABLE=/home/user/miniconda3/envs/py310/bin/python \
-DPYTHON3_LIBRARY=/home/user/miniconda3/envs/py310/lib/libpython3.10.so \
-DPYTHON3_PACKAGES_PATH=/home/user/miniconda3/envs/py310/lib/python3.10/site-packages \
-DPYTHON_INCLUDE_DIR=/home/user/miniconda3/envs/py310/include/python3.10 \
-DPYTHON3_NUMPY_INCLUDE_DIRS=/home/user/miniconda3/envs/py310/lib/python3.10/site-packages/numpy/core/include/numpy \
-DCMAKE_VERBOSE_MAKEFILE=ON"
export ENABLE_CONTRIB=1
export VERBOSE=1
- Run:
pip wheel . --verbose
- operating system
- Ubuntu 22.04
- architecture (e.g. x86)
- x86_64
- opencv-python version
- 4.6.0.66
Issue submission checklist
- This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
- I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
- The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
- I'm using the latest version of
opencv-python
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported pip wheel . --verbose build on Ubuntu 22.04 with Python 3.10.4 and the supplied CMAKE_ARGS, then inspect how the build configuration consumes PYTHON3_NUMPY_INCLUDE_DIRS. Done means the requested NumPy include-directory override is accepted and the opencv-python wheel builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, python, ubuntu
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100