huihut / OpenCV-MinGW-Build

👀 MinGW 32bit and 64bit version of OpenCV compiled on Windows. Including OpenCV 3.3.1, 3.4.1, 3.4.1-x64, 3.4.5, 3.4.6, 3.4.7, 3.4.8-x64, 3.4.9, 4.0.0-alpha-x64, 4.0.0-rc-x64, 4.0.1-x64, 4.1.0, 4.1.0-x64, 4.1.1-x64, 4.5.0-with-contrib, 4.5.2-x64
https://opencv.org/
928 stars 215 forks source link

Unable to import cv2 using `OpenCV-MinGW-Build-OpenCV-4.0.1-x64` #6

Closed iongion closed 5 years ago

iongion commented 5 years ago

Using: msys2

$ uname -a
MINGW64_NT-10.0 gion-pc 2.11.2(0.329/5/3) 2018-11-26 09:22 x86_64 Msys

$ python3 --version
Python 3.7.0

I have installed it using:

istoica@gion-pc MINGW64 /W/Workspace/OpenCV-MinGW-Build-OpenCV-4.0.1-x64/python
$ python3 setup.py install
running install
running bdist_egg
running egg_info
writing opencv.egg-info/PKG-INFO
writing dependency_links to opencv.egg-info/dependency_links.txt
writing requirements to opencv.egg-info/requires.txt
writing top-level names to opencv.egg-info/top_level.txt
reading manifest file 'opencv.egg-info/SOURCES.txt'
writing manifest file 'opencv.egg-info/SOURCES.txt'
installing library code to build/bdist.mingw/egg
running install_lib
running build_py
creating build/bdist.mingw/egg
creating build/bdist.mingw/egg/cv2
copying build/lib/cv2/config.py -> build/bdist.mingw/egg/cv2
copying build/lib/cv2/load_config_py2.py -> build/bdist.mingw/egg/cv2
copying build/lib/cv2/load_config_py3.py -> build/bdist.mingw/egg/cv2
copying build/lib/cv2/__init__.py -> build/bdist.mingw/egg/cv2
byte-compiling build/bdist.mingw/egg/cv2/config.py to config.cpython-37.pyc
byte-compiling build/bdist.mingw/egg/cv2/load_config_py2.py to load_config_py2.cpython-37.pyc
byte-compiling build/bdist.mingw/egg/cv2/load_config_py3.py to load_config_py3.cpython-37.pyc
byte-compiling build/bdist.mingw/egg/cv2/__init__.py to __init__.cpython-37.pyc
creating build/bdist.mingw/egg/EGG-INFO
copying opencv.egg-info/PKG-INFO -> build/bdist.mingw/egg/EGG-INFO
copying opencv.egg-info/SOURCES.txt -> build/bdist.mingw/egg/EGG-INFO
copying opencv.egg-info/dependency_links.txt -> build/bdist.mingw/egg/EGG-INFO
copying opencv.egg-info/requires.txt -> build/bdist.mingw/egg/EGG-INFO
copying opencv.egg-info/top_level.txt -> build/bdist.mingw/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
cv2.__pycache__.__init__.cpython-37: module references __file__
creating 'dist/opencv-4.0.0-py3.7.egg' and adding 'build/bdist.mingw/egg' to it
removing 'build/bdist.mingw/egg' (and everything under it)
Processing opencv-4.0.0-py3.7.egg
removing 'W:/sdks/msys2/mingw64/lib/python3.7/site-packages/opencv-4.0.0-py3.7.egg' (and everything under it)
creating W:/sdks/msys2/mingw64/lib/python3.7/site-packages/opencv-4.0.0-py3.7.egg
Extracting opencv-4.0.0-py3.7.egg to W:/sdks/msys2/mingw64/lib/python3.7/site-packages
opencv 4.0.0 is already the active version in easy-install.pth

Installed w:/sdks/msys2/mingw64/lib/python3.7/site-packages/opencv-4.0.0-py3.7.egg
Processing dependencies for opencv==4.0.0
Searching for numpy==1.15.0
Best match: numpy 1.15.0
Adding numpy 1.15.0 to easy-install.pth file
Installing conv-template-script.py script to W:/SDKs/msys2/mingw64/bin
Installing conv-template.exe script to W:/SDKs/msys2/mingw64/bin
Installing f2py-script.py script to W:/SDKs/msys2/mingw64/bin
Installing f2py.exe script to W:/SDKs/msys2/mingw64/bin
Installing from-template-script.py script to W:/SDKs/msys2/mingw64/bin
Installing from-template.exe script to W:/SDKs/msys2/mingw64/bin

Using w:/sdks/msys2/mingw64/lib/python3.7/site-packages
Finished processing dependencies for opencv==4.0.0

But I get this output, unable to import cv2:

$ python3
Python 3.7.0 (default, Aug  3 2018, 11:56:18)  [GCC 8.2.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "W:/Workspace/OpenCV-MinGW-Build-OpenCV-4.0.1-x64/python\cv2\__init__.py", line 89, in <module>
    bootstrap()
  File "W:/Workspace/OpenCV-MinGW-Build-OpenCV-4.0.1-x64/python\cv2\__init__.py", line 62, in bootstrap
    ], True)
  File "W:/Workspace/OpenCV-MinGW-Build-OpenCV-4.0.1-x64/python\cv2\__init__.py", line 56, in load_first_config
    raise ImportError('OpenCV loader: missing configuration file: {}. Check OpenCV installation.'.format(fnames))
ImportError: OpenCV loader: missing configuration file: ['config-3.7.py', 'config-3.py']. Check OpenCV installation.

What must I do to get it working ?

huihut commented 5 years ago

Sorry, I only checked the default configuration and did not check python. You can see Configuration.

OpenCV modules:
    Unavailable:                 java js python2 python3
......
Python (for build):            NO

If you want to use opencv in python, please check it and compile it yourself.