9

When I execute this command:

pip3 install opencv-python

I get the following error:

  Installing build dependencies ... error                            ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-z4c_sn6u/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel scikit-build cmake pip 'numpy==1.11.3; python_version=='"'"'3.5'"'"'' 'numpy==1.13.3; python_version=='"'"'3.6'"'"'' 'numpy==1.14.5; python_version=='"'"'3.7'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"''       cwd: None
  Complete output (22 lines):
  Ignoring numpy: markers 'python_version == "3.5"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.6"' don't match your environment
  Ignoring numpy: markers 'python_version == "3.7"' don't match your environment
  Collecting setuptools
    Downloading setuptools-49.6.0-py3-none-any.whl (803 kB)
  Collecting wheel
    Downloading wheel-0.35.0-py2.py3-none-any.whl (24 kB)
  Collecting scikit-build
    Using cached scikit_build-0.11.1-py2.py3-none-any.whl (72 kB)
  Collecting cmake
    Using cached cmake-3.18.0.tar.gz (28 kB)
      ERROR: Command errored out with exit status 1:
       command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-95tsmt_u/cmake/setup.py'"'"'; __file__='"'"'/tmp/pip-install-95tsmt_u/cmake/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-95tsmt_u/cmake/pip-egg-info
           cwd: /tmp/pip-install-95tsmt_u/cmake/
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/tmp/pip-install-95tsmt_u/cmake/setup.py", line 7, in <module>
          from skbuild import setup
      ModuleNotFoundError: No module named 'skbuild'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 /usr/lib/python3/dist-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-z4c_sn6u/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel scikit-build cmake pip 'numpy==1.11.3; python_version=='"'"'3.5'"'"'' 'numpy==1.13.3; python_version=='"'"'3.6'"'"'' 'numpy==1.14.5; python_version=='"'"'3.7'"'"'' 'numpy==1.17.3; python_version>='"'"'3.8'"'"'' Check the logs for full command output.

Same when I tried to install ecapture, I am using the latest python version

yatu
  • 86,083
  • 12
  • 84
  • 139
Dmirty Trecenko
  • 107
  • 1
  • 1
  • 8

8 Answers8

9

Try to upgrade your pip with

pip install --upgrade pip

and then run the

pip install opencv-python
Gautamrk
  • 1,144
  • 9
  • 12
9

Installation and Usage guide on pypi web site says

Pip install fails with ModuleNotFoundError: No module named 'skbuild'?

Since opencv-python version 4.3.0.*, manylinux1 wheels were replaced by manylinux2014 wheels. If your pip is too old, it will try to use the new source distribution introduced in 4.3.0.38 to manually build OpenCV because it does not know how to install manylinux2014 wheels. However, source build will also fail because of too old pip because it does not understand build dependencies in pyproject.toml. To use the new manylinux2014 pre-built wheels (or to build from source), your pip version must be >= 19.3.
Please upgrade pip with
pip install --upgrade pip

zzz
  • 99
  • 7
  • Didn't help, pip3 install --upgrade pip it's important for me to use pip3 – Dmirty Trecenko Aug 14 '20 at 10:14
  • @DmirtyTrecenko What version of pip3 do you use? Show output of that command: pip3 --version Also check this answer: https://stackoverflow.com/a/40832677/11278441 – zzz Aug 14 '20 at 10:29
  • pip 20.0.2 from use/lib/python3/dist-packages/pip (python 3.8) – Dmirty Trecenko Aug 14 '20 at 10:33
  • I tested this on pip 20.2.2 using pip3 and it works. Try to update pip to 20.2.2 version using this command: pip3 install --upgrade pip – zzz Aug 14 '20 at 11:08
  • Okay, now it writes Successfully installed pip 20.2.2 but command --version outputs old version – Dmirty Trecenko Aug 14 '20 at 11:29
  • Magic! You might probably checked pip version not pip3, or idk. – zzz Aug 14 '20 at 11:34
  • ```root@kali:/# pip3 install --upgrade pip Collecting pip Using cached pip-20.2.2-py2.py3-none-any.whl (1.5 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.0.2 Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr Can't uninstall 'pip'. No files were found to uninstall. Successfully installed pip-20.2.2 root@kali:/# pip3 --version pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)``` – Dmirty Trecenko Aug 14 '20 at 11:48
  • It's very likely that `pip` cannot be easily upgraded / upgrade fails silently with that default upgrade command if it has been originally installed via your Linux distribution repositories (the system repository maintainers should keep `pip` up-to-date but looks like many distros ship with 2,5+ year or even 5+ year old `pip` version). My recommendation would be to use `virtualenv` (https://docs.python.org/3/library/venv.html) whenever possible. Then the most recent versions of Python tooling are always available / easily upgradeable. – skvark Aug 14 '20 at 18:40
9

I was facing this similar situation:

Dockerfile:

FROM nvidia/cuda:10.0-cudnn7-runtime-ubuntu18.04

RUN apt-get update -y
RUN apt-get install -y vim curl iputils-ping python3-dev python3-pip libsm6 
libxext6 libxrender-dev python3.6
RUN pip3 install -r /requirements.txt
...

requirements.txt:

...
opencv-python
...

Upon running docker-compose up &, I was receiving this error:

 Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "/tmp/pip-build-acog3xol/opencv-python/setup.py", line 9, in <module>
     import skbuild
 ModuleNotFoundError: No module named 'skbuild'

I tried the suggested solutions of upgrading pip3 but was getting the same problem.

What worked for me was fixing the opencv-python version in requirements.txt. Previously, it was pulling version 4.4.0.40. I instead changed requirements.txt to:

...
opencv-python==4.2.0.34
...
Dharman
  • 30,962
  • 25
  • 85
  • 135
user1145925
  • 971
  • 3
  • 13
  • 24
3

If you go to the opencv-python PyPi page they will give troubleshooting tips for common errors. See opencv-python 4.4.0.40

The error you're encountering is:

ModuleNotFoundError: No module named 'skbuild'

The fix for this is listed under the FAQ as follows:


Q: Pip install fails with ModuleNotFoundError: No module named 'skbuild'?

Since opencv-python version 4.3.0.*, manylinux1 wheels were replaced by manylinux2014 wheels. If your pip is too old, it will try to use the new source distribution introduced in 4.3.0.38 to manually build OpenCV because it does not know how to install manylinux2014 wheels. However, source build will also fail because of too old pip because it does not understand build dependencies in pyproject.toml. To use the new manylinux2014 pre-built wheels (or to build from source), your pip version must be >= 19.3. Please upgrade pip with pip install --upgrade pip.

TLDR:

pip install --upgrade pip
Robert Young
  • 456
  • 2
  • 8
3

Try this :

pip3 install cmake --user

pip3 install --upgrade pip --user

pip3 install opencv-python --user

bulgarian-beast
  • 367
  • 3
  • 10
2

Python 3.8 was not working for me too. Now installing using Python 3.7, and it looks ok though still in progress:

python3.7 -m pip install opencv-python==4.3.0.38
Patrick
  • 1,046
  • 2
  • 10
  • 31
ChanHK
  • 21
  • 1
1

Use Python 3.7.6 this is the most stable version. there are many things that don't install on 3.8.

gulbaz khan
  • 175
  • 1
  • 9
0

you need to install sbuild via pip. you can follow the below command. It worked on my pc.

python3 -m pip install scikit-build

Best of Luck for you.

Deepak Raj
  • 462
  • 5
  • 15