opencv-python: Pip build fails: FileNotFoundError: [Errno 2] No such file or directory: 'scripts/__init__.py'
Reproduce:
pip install --upgrade pip setuptools wheel
CMAKE_ARGS="-DOPENCV_ENABLE_NONFREE=ON" pip install -v --no-binary=opencv-contrib-python opencv-contrib-python
Related PR: https://github.com/opencv/opencv-python/pull/563
Error:
Configuring Project
Working directory:
/tmp/pip-install-ais_cble/opencv-python_36817dc5e0834847b9d8f8f1dc7bd3c4/_skbuild/linux-x86_64-3.8/cmake-build
Command:
cmake /tmp/pip-install-ais_cble/opencv-python_36817dc5e0834847b9d8f8f1dc7bd3c4/opencv -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-ais_cble/opencv-python_36817dc5e0834847b9d8f8f1dc7bd3c4/_skbuild/linux-x86_64-3.8/cmake-install -DPYTHON_EXECUTABLE:FILEPATH=/home/elmeri/.venv/ml/bin/python3.8 -DPYTHON_VERSION_STRING:STRING=3.8.12 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.8 -DPYTHON_LIBRARY:FILEPATH=/usr/lib/libpython3.8.so -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-bo2trral/overlay/lib/python3.8/site-packages/skbuild/resources/cmake -DPYTHON3_EXECUTABLE=/home/elmeri/.venv/ml/bin/python3.8 -DPYTHON3_INCLUDE_DIR=/usr/include/python3.8 -DPYTHON3_LIBRARY=/usr/lib/libpython3.8.so -DBUILD_opencv_python3=ON -DBUILD_opencv_python2=OFF -DBUILD_opencv_java=OFF -DOPENCV_PYTHON3_INSTALL_PATH=python -DINSTALL_CREATE_DISTRIB=ON -DBUILD_opencv_apps=OFF -DBUILD_opencv_freetype=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_DOCS=OFF -DOPENCV_ENABLE_NONFREE=ON -DCMAKE_BUILD_TYPE:STRING=Release
Copying files from CMake output
Traceback (most recent call last):
File "/home/elmeri/.venv/ml/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
main()
File "/home/elmeri/.venv/ml/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/elmeri/.venv/ml/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 248, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-bo2trral/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 221, in build_wheel
return self._build_with_temp_dir(['bdist_wheel'], '.whl',
File "/tmp/pip-build-env-bo2trral/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 207, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-bo2trral/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 258, in run_setup
super(_BuildMetaLegacyBackend,
File "/tmp/pip-build-env-bo2trral/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 496, in <module>
main()
File "setup.py", line 248, in main
skbuild.setup(
File "/tmp/pip-build-env-bo2trral/overlay/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 625, in setup
_classify_installed_files(cmake_manifest, package_data, package_prefixes,
File "setup.py", line 381, in _classify_installed_files_override
with open('scripts/__init__.py', 'r') as custom_init:
FileNotFoundError: [Errno 2] No such file or directory: 'scripts/__init__.py'
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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 28 (7 by maintainers)
Commits related to this issue
- fix opencv-python installation in Dockerfile Related: https://github.com/opencv/opencv-python/issues/571 — committed to daniel-richter/DIN_GAR by daniel-richter 3 years ago
- fix opencv-python installation in Dockerfile Related: https://github.com/opencv/opencv-python/issues/571 — committed to daniel-richter/DIN_GAR by deleted user 3 years ago
- fix opencv-python installation in Dockerfile Related: https://github.com/opencv/opencv-python/issues/571 — committed to daniel-richter/DIN_GAR by deleted user 3 years ago
- fix opencv-python installation in Dockerfile Related: https://github.com/opencv/opencv-python/issues/571 — committed to daniel-richter/DIN_GAR by daniel-richter 3 years ago
- fix opencv-python installation in Dockerfile (#10) Related: https://github.com/opencv/opencv-python/issues/571 — committed to JacobYuan7/DIN-Group-Activity-Recognition-Benchmark by daniel-richter 3 years ago
- Unpin opencv-python-headless version. See https://github.com/opencv/opencv-python/issues/571 for the related discussion. PiperOrigin-RevId: 411686231 — committed to tensorflow/tfx by deleted user 3 years ago
- Unpin opencv-python-headless version. See https://github.com/opencv/opencv-python/issues/571 for the related discussion. PiperOrigin-RevId: 411686231 — committed to tensorflow/tfx by deleted user 3 years ago
- Unpin opencv-python-headless version. See https://github.com/opencv/opencv-python/issues/571 for the related discussion. PiperOrigin-RevId: 411686231 — committed to tensorflow/tfx by deleted user 3 years ago
- Unpin opencv-python-headless version. See https://github.com/opencv/opencv-python/issues/571 for the related discussion. PiperOrigin-RevId: 411728512 — committed to tensorflow/tfx by deleted user 3 years ago
Installing the previous version succeeds using the following command:
pip install opencv-python==4.5.3.56
Workaround is to use an older release:
CMAKE_ARGS="-DOPENCV_ENABLE_NONFREE=ON" pip install -v --no-binary=opencv-contrib-python opencv-contrib-python==4.5.3.56
In my case, upgrading to the last pip version fixed the problem:
@asenyaev will this be fixed soon?
Failed on a Raspberry PI 4 with Debian buster Python: 3.7.3 pip: 21.3.1
Also the builds fails on piwheels: https://www.piwheels.org/project/opencv-python-headless/
Keeps the error
@tfuto, if you tried to just install opencv-python, I guess it means that you use a latest version (4.6.0.66). However, I couldn’t reproduce an issue with the latest version of opencv-python package on Ubuntu 22.04 LTS.
Even the build from source using the command
python3 -m pip install -v --no-binary=opencv-python-headless opencv-python-headless==4.6.0.66
finished successufully:Fixed in 4.5.4.60. Tested with Ubuntu 18.04 and command:
Faced this inside docker container on Nvidia Jetson nano, this fixed it for me too
The piwheels version availability chart for this project looks like a minefield.
… so that’s why “pip3 install opencv-python” failed.
FileNotFoundError: [Errno 2] No such file or directory: ‘scripts/init.py’ 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
Too bad it takes hours of compiling before this error appears. From which version is this fixed? (Thanks 😃 )
OS: Raspbian 10 Python: 3.7.3.
Same error for me 😦
@elmeriniemela thank you for your feedback!
At the moment, we hardly depends on files in opencv-python repository, especially on
scripts
folder, to build the proper package. I will remove this dependency to solve the issue.I determined the issue that caused my build to fail:
The latest version of numpy is incompatible with Python 3.10.0. Link to numpy known issue.
This is extraordinarily confusing because the precompiled binary for numpy, installable via pip, successfully installs in Python 3 - but the build process for opencv-python requires rebuilding numpy from source, and that process fails under 3.10.0.
Installing Python 3.9.7, making that version global (via pyenv), and building opencv-python for Python 3.9.7 was successful.