opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.43k stars 833 forks source link

problem with installation with the newest version 4.3.0.38 and python 3.6.8 #371

Closed mkrajnak closed 4 years ago

mkrajnak commented 4 years ago

Expected behaviour

The older version works fine:

$ pip3 install --user opencv-python==4.2.0.34
Collecting opencv-python==4.2.0.34
  Downloading https://files.pythonhosted.org/packages/72/c2/e9cf54ae5b1102020ef895866a67cb2e1aef72f16dd1fde5b5fb1495ad9c/opencv_python-4.2.0.34-cp36-cp36m-manylinux1_x86_64.whl (28.2MB)
    100% |████████████████████████████████| 28.2MB 67kB/s 
Collecting numpy>=1.11.3 (from opencv-python==4.2.0.34)
  Downloading https://files.pythonhosted.org/packages/22/e7/4b2bdddb99f5f631d8c1de259897c2b7d65dcfcc1e0a6fd17a7f62923500/numpy-1.19.1-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
    100% |████████████████████████████████| 13.4MB 145kB/s 
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.19.1 opencv-python-4.2.0.34

Actual behaviour

$ pip3 install --user opencv-python 
Collecting opencv-python
  Using cached https://files.pythonhosted.org/packages/a1/d6/8422797e35f8814b1d9842530566a949d9b5850a466321a6c1d5a99055ee/opencv-python-4.3.0.38.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-467m552x/opencv-python/setup.py", line 9, in <module>
        import skbuild
    ModuleNotFoundError: No module named 'skbuild'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-467m552x/opencv-python/

Steps to reproduce

$ pip3 install --user opencv-python 

this is happening on rhel8 (fresh install. no previous versions of opencv installed), python3 version:

python3                           
Python 3.6.8 (default, Jun 26 2020, 12:10:09) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Workarounds that I have tried (stack overflow):

$ pip3 install --user cmake scikit-build
....
$   pip3 install --user opencv-python            
Collecting opencv-python
  Using cached https://files.pythonhosted.org/packages/a1/d6/8422797e35f8814b1d9842530566a949d9b5850a466321a6c1d5a99055ee/opencv-python-4.3.0.38.tar.gz
Requirement already satisfied: numpy>=1.13.3 in /home/mkrajnak/.local/lib/python3.6/site-packages (from opencv-python)
Building wheels for collected packages: opencv-python
  Running setup.py bdist_wheel for opencv-python ... error
  Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-78o09h7e/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpvcmmhhevpip-wheel- --python-tag cp36:
  Traceback (most recent call last):
    File "/home/mkrajnak/.local/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
      cmkr = cmaker.CMaker(cmake_executable)
    File "/home/mkrajnak/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
      self.cmake_version = get_cmake_version(self.cmake_executable)
    File "/home/mkrajnak/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
      "Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)

  Problem with the CMake installation, aborting build. CMake executable is cmake

  ----------------------------------------
  Failed building wheel for opencv-python
  Running setup.py clean for opencv-python
Failed to build opencv-python
Installing collected packages: opencv-python
  Running setup.py install for opencv-python ... error
    Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-78o09h7e/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-skxs1drk-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    Traceback (most recent call last):
      File "/home/mkrajnak/.local/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
        cmkr = cmaker.CMaker(cmake_executable)
      File "/home/mkrajnak/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
        self.cmake_version = get_cmake_version(self.cmake_executable)
      File "/home/mkrajnak/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 82, in get_cmake_version
        "Problem with the CMake installation, aborting build. CMake executable is %s" % cmake_executable)

    Problem with the CMake installation, aborting build. CMake executable is cmake

    ----------------------------------------
Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-78o09h7e/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-skxs1drk-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-78o09h7e/opencv-python/

I believe the python3.6 is supported, I am using the opencv-python==4.2.0.34 as a workaround for now, were there new dependencies added between the versions? Do I really need cmake to make opencv work?

If the issue is common, I am sorry I've spent some time on this a couldn't find anything helpful.

skvark commented 4 years ago

What's the version of pip? pip >= 19.3 is required for the two latest releases due to manylinux2014. Check the release notes: https://github.com/skvark/opencv-python/releases/tag/36

pip tries to compile from source because it does not find compatible pre-built wheels. Manylinux pip version requirement table is here: https://github.com/pypa/manylinux#manylinux

You can upgrade pip with (also found from the README of this repository): pip install --upgrade pip

mkrajnak commented 4 years ago

Yes you are right, I didn't notice that the machine comes with the older version of pip, sudo pip3 install --upgrade pip solved this for me. Thanks a lot !

andreish commented 4 years ago

please consider reopen:

docker build -t testo-opecv-python .

=========== Dockerfile ============== FROM ubuntu:18.04

ENV LANG=en_US.UTF-8 \ LC_ALL=en_US.UTF-8

RUN echo "$LOG_TAG update and install basic packages" && \ apt-get -y update && \ apt-get install -y locales apt-utils && \ locale-gen $LANG && update-locale $LANG && \ apt-get install -y software-properties-common && \ apt-get install -y build-essential pkg-config libffi-dev

RUN apt-get install -y python-pip

RUN pip install --upgrade pip && \ pip --version && \ pip install wheel && \ pip install opencv-python

==================================

this fails to build with:

/pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting opencv-python Downloading opencv-python-4.3.0.38.tar.gz (88.0 MB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'error' ERROR: Command errored out with exit status 1: command: /usr/bin/python /usr/local/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpkrD0Rd cwd: /tmp/pip-install-MC24hE/opencv-python Complete output (22 lines): Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py", line 280, in main() File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py", line 114, in get_requires_for_build_wheel return hook(config_settings) File "/tmp/pip-build-env-nV6VDw/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 146, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) File "/tmp/pip-build-env-nV6VDw/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 127, in _get_build_requires self.run_setup() File "/tmp/pip-build-env-nV6VDw/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 243, in run_setup self).run_setup(setup_script=setup_script) File "/tmp/pip-build-env-nV6VDw/overlay/lib/python2.7/site-packages/setuptools/build_meta.py", line 142, in run_setup exec(compile(code, file, 'exec'), locals()) File "setup.py", line 448, in main() File "setup.py", line 99, in main % {"ext": re.escape(sysconfig.get_config_var("EXT_SUFFIX"))} File "/usr/lib/python2.7/re.py", line 210, in escape s = list(pattern) TypeError: 'NoneType' object is not iterable

ERROR: Command errored out with exit status 1: /usr/bin/python /usr/local/lib/python2.7/dist-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpkrD0Rd Check the logs for full command output. The command '/bin/sh -c pip install --upgrade pip && pip --version && pip install wheel && pip install opencv-python' returned a non-zero code: 1

This works

FROM ubuntu:18.04

ENV LANG=en_US.UTF-8 \ LC_ALL=en_US.UTF-8

RUN echo "$LOG_TAG update and install basic packages" && \ apt-get -y update && \ apt-get install -y locales apt-utils && \ locale-gen $LANG && update-locale $LANG && \ apt-get install -y software-properties-common && \ apt-get install -y build-essential pkg-config libffi-dev

RUN apt-get install -y python-pip

RUN pip install --upgrade pip && \ pip --version && \ pip install wheel && \ pip install opencv-python==4.2.0.32

last week I could build with latest 4.3.0.36 and got a container with

root@92f802180a93:/zeppelin# pip list | grep opencv opencv-python 4.3.0.36

skvark commented 4 years ago

Python 2.7 hasn't been supported since 4.3.0.36. Your pip points most likely to Python 2.7. Use pip3 instead. There is no Python 2.7 wheels for 4.3.0.36 or source distribution (https://pypi.org/project/opencv-python/4.3.0.36/#files) so you must have used Python 3 for that working version.

andreish commented 4 years ago

Thank you, using pip3 fixes it .