Skip to content

ImportError: OpenCV loader: missing configuration file #1039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arielkantorovich opened this issue Oct 21, 2024 · 2 comments
Closed

ImportError: OpenCV loader: missing configuration file #1039

arielkantorovich opened this issue Oct 21, 2024 · 2 comments

Comments

@arielkantorovich
Copy link

Environment

WSL2 - Ubuntu 22.04
miniconda env with python 3.10 version
Opencv version 4.10

Steps to reproduce

I try to compile Opencv with CUDA on my wsl2 machine. here is my Cmake file list:
cmake
-D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-D WITH_CUDA=ON
-D WITH_CUDNN=ON
-D WITH_CUBLAS=ON
-D WITH_TBB=ON
-D OPENCV_DNN_CUDA=ON
-D OPENCV_ENABLE_NONFREE=ON
-D WITH_GSTREAMER=ON
-D WITH_V4L=ON
-D WITH_LIBV4L=ON
-D CUDA_ARCH_BIN=8.6
-D OPENCV_EXTRA_MODULES_PATH=$HOME/opencv_contrib/modules
-D BUILD_EXAMPLES=OFF
-D HAVE_opencv_python3=ON
..

Succeed to compile and finish.
Succeed to install on conda env using pip3 install opencv/build/python_loader

Issue

Try import cv2 from python and get the following error:

import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/arielka/opencv/build/python_loader/cv2/__init__.py", line 181, in <module> bootstrap() File "/home/arielka/opencv/build/python_loader/cv2/__init__.py", line 112, in bootstrap load_first_config([ File "/home/arielka/opencv/build/python_loader/cv2/__init__.py", line 109, in load_first_config raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames)) ImportError: OpenCV loader: missing configuration file: ['config-3.10.py', 'config-3.py']. Check OpenCV installation.

@asmorkalov
Copy link
Collaborator

Should be fixed in #1000

@arielkantorovich
Copy link
Author

arielkantorovich commented Jan 15, 2025

Thank you I am not really understand I need change setup.py file in python loader or uninstall and recompile everything once again?
Here is my setup.py
`import os
import setuptools

SCRIPT_DIR = os.path.dirname(os.path.abspath(file))

def collect_module_typing_stub_files(root_module_path):
stub_files = []
for module_path, _, files in os.walk(root_module_path):
stub_files.extend(
map(lambda p: os.path.join(module_path, p),
filter(lambda f: f.endswith(".pyi"), files))
)
return stub_files

def main():
os.chdir(SCRIPT_DIR)

package_name = 'opencv'
package_version = os.environ.get('OPENCV_VERSION', '4.10.0')  # TODO

long_description = 'Open Source Computer Vision Library Python bindings'  # TODO

root_module_path = os.path.join(SCRIPT_DIR, "cv2")
py_typed_path = os.path.join(root_module_path, "py.typed")
typing_stub_files = []
if os.path.isfile(py_typed_path):
    typing_stub_files = collect_module_typing_stub_files(root_module_path)
    if len(typing_stub_files) > 0:
        typing_stub_files.append(py_typed_path)

setuptools.setup(
    name=package_name,
    version=package_version,
    url='https://github.com/opencv/opencv',
    license='Apache 2.0',
    description='OpenCV python bindings',
    long_description=long_description,
    long_description_content_type="text/markdown",
    packages=setuptools.find_packages(),
    package_data={
        "cv2": typing_stub_files
    },
    maintainer="OpenCV Team",
    install_requires="numpy",
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Environment :: Console",
        "Intended Audience :: Developers",
        "Intended Audience :: Education",
        "Intended Audience :: Information Technology",
        "Intended Audience :: Science/Research",
        "License :: OSI Approved :: Apache Software License",
        "Operating System :: MacOS",
        "Operating System :: Microsoft :: Windows",
        "Operating System :: POSIX",
        "Operating System :: Unix",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3 :: Only",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: C++",
        "Programming Language :: Python :: Implementation :: CPython",
        "Topic :: Scientific/Engineering",
        "Topic :: Scientific/Engineering :: Image Recognition",
        "Topic :: Software Development",
    ],
)

if name == 'main':
main()`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants