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

OpenCV 3.4.4 Python binding #13202

Open
h6197627 opened this Issue Nov 18, 2018 · 7 comments

Comments

6 participants
@h6197627

h6197627 commented Nov 18, 2018

In newly released OpenCV 3.4.4 python bindings installation process was changed. Now it creates new folder /usr/local/python with python binding stuff. To make it visible in python user should run setup script from this folder. However after installation I am getting error:

>>> import cv2
['/usr/local/lib/python3.6/dist-packages/opencv-3.4.4-py3.6.egg/cv2/../../python/cv2/python-3.6', '', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/local/lib/python3.6/dist-packages/scipy-1.1.0-py3.6-linux-x86_64.egg', '/usr/local/lib/python3.6/dist-packages/protobuf-3.6.1-py3.6-linux-x86_64.egg', '/usr/local/lib/python3.6/dist-packages/pycuda-2018.1.1-py3.6-linux-x86_64.egg', '/usr/local/lib/python3.6/dist-packages/Mako-1.0.7-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/appdirs-1.4.3-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/decorator-4.3.0-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/pytest-3.9.3-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/pytools-2018.5.2-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/MarkupSafe-1.0-py3.6-linux-x86_64.egg', '/usr/local/lib/python3.6/dist-packages/py-1.7.0-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/pluggy-0.8.0-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/more_itertools-4.3.0-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/attrs-18.2.0-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/atomicwrites-1.2.1-py3.6.egg', '/usr/local/lib/python3.6/dist-packages/numpy-1.15.4-py3.6-linux-x86_64.egg', '/usr/local/lib/python3.6/dist-packages/opencv-3.4.4-py3.6.egg', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/opencv-3.4.4-py3.6.egg/cv2/__init__.py", line 89, in <module>
    bootstrap()
  File "/usr/local/lib/python3.6/dist-packages/opencv-3.4.4-py3.6.egg/cv2/__init__.py", line 79, in bootstrap
    import cv2
  File "/usr/local/lib/python3.6/dist-packages/opencv-3.4.4-py3.6.egg/cv2/__init__.py", line 89, in <module>
    bootstrap()
  File "/usr/local/lib/python3.6/dist-packages/opencv-3.4.4-py3.6.egg/cv2/__init__.py", line 23, in bootstrap
    raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

Also I have another question - is it possible to configure CMake to use only Ubuntu OS dedicated folders for python binding installation (/usr/local/lib/pythonX.X/dist-packages) without creating new non-standard directories (/usr/local/python)?

System information (version)
  • OpenCV => 3.4.4
  • Operating System / Platform => Ubuntu 18.04
  • Compiler => GCC
Steps to reproduce
  1. build OpenCV with python bindings
  2. cd /usr/local/python
  3. sudo python3 setup.py install
  4. python3
  5. import cv2

@alalek

This comment has been minimized.

Contributor

alalek commented Nov 18, 2018

There are these options:

  1. Don't install this loader package (it is mostly for standalone distributions): #12977 (comment)

Old behavior can restored via these CMake variables:

  • OPENCV_SKIP_PYTHON_LOADER=ON
  • OPENCV_PYTHON3_INSTALL_PATH=...site/dist-packages location... (not required since #13254)
  1. setup.py is not complete for now and its usage is very limited (it is a bit tricky to install native binaries with their dependencies in Python). Try to install this loader in develop mode instead:
python3 setup.py develop
or
pip install -e .
  1. There is bug with paths:

opencv-3.4.4-py3.6.egg/cv2/../../python/cv2/python-3.6

should be

opencv-3.4.4-py3.6.egg/cv2/python-3.6

@alalek alalek self-assigned this Nov 18, 2018

iporty referenced this issue Nov 18, 2018

removed C API in the following modules: photo, video, imgcodecs, vide…
…oio (#13060)

* removed C API in the following modules: photo, video, imgcodecs, videoio

* trying to fix various compile errors and warnings on Windows and Linux

* continue to fix compile errors and warnings

* continue to fix compile errors, warnings, as well as the test failures

* trying to resolve compile warnings on Android

* Update cap_dc1394_v2.cpp

fix warning from the new GCC
@h6197627

This comment has been minimized.

h6197627 commented Nov 19, 2018

Thanks @alalek for helping! I will use old approach for now.

@wangqr

This comment has been minimized.

wangqr commented Nov 21, 2018

The printed path in the archlinux package includes '/build/opencv/src/build/lib/python3', which seems to be the building directory. Is this the expected behavior with the new loader?

@sergiomb2

This comment has been minimized.

Contributor

sergiomb2 commented Dec 2, 2018

huf ! , you need do another release , install pyhton path are wrong , and just after a complete build we notice it, I spent one day to find it .

@tomrunia

This comment has been minimized.

tomrunia commented Dec 12, 2018

I ran into the same error with OpenCV 4.0.0 on MacOS with Python 3.7.
This fixed it for me: python3 setup.py develop

@sergiomb2

This comment has been minimized.

Contributor

sergiomb2 commented Dec 13, 2018

Old behavior can restored via these CMake variables:

OPENCV_SKIP_PYTHON_LOADER=ON

2 questions

  • Why new behavior is default instead old behavior ?
  • What is the benefits of the new behavior ? ( which in Fedora packages seems that install python bindings in a not standard folder)
@edrozenberg

This comment has been minimized.

edrozenberg commented Dec 14, 2018

Ran into this also. Was not fun, and also my package created using make install DESTDIR now requires an additional non-standard, non-discoverable manual step to get the bindings set up after the package is installed on each target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment