opencv-python: ModuleNotFoundError: No module named 'skbuild'

Expected behaviour

I was trying to install it with :

!{sys.executable} -m pip install --user opencv-python

Actual behaviour

Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-rnhk49o3/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-rnhk49o3/opencv-python/

Steps to reproduce

  • Ubuntu 18 LTS
  • Jupyter Notebook
  • x86
  • opencv-python version : to-be installed
Issue submission checklist
  • This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

@skvark Installing scikit-build before attempting to install opencv made opencv successful on my Raspberry Pi 4. My end goal is still to get stable-baselines to function properly, and it won’t finish its install. However, it is no longer getting stopped by its opencv requirements. It is always one step forward and three steps back trying to get anything to work on Pis. I just thought I’d let you know that it at least seemed to install properly when I took care of the scikit-build requirement manually as such:

pip3 install scikit-build pip3 install opencv-python

Please post full list of commands you used when you encountered the error so I can try to reproduce it - if there’s some bug in how build dependencies are defined in pyproject.toml I’m happy to fix it. If there’s some bug in pip I will report it to pip maintainers. However, in my experience from answering tens of these questions the answer has been always too old pip. On arm64 architectures (and on arm in general) the story is a bit different, since scikit-build depends on cmake arm64 binary which is currently broken and prevents scikit-build from working properly.

As noted above, also the original issue here was about too old pip: the problem was that system pip was used instead of the jupyter-notebook’s own pip (or something, I don’t know how jupyter works behind the scenes).

Ubuntu and other Linux systems ship usually with very old pip versions (< 10) and there are usually many different pip executables in those systems. For example, pip usually points to Python 2.7 and pip3 points to some Python 3 version. When you try to update those with pip itself the update might fail due to the fact that they are provided via Linux system package repositories and not via get-pip.py. Therefore, the build should be run always in a clean virtualenv with fresh tools.

All this boils down to Python’s package management system. I hope it will be some day a bit simpler to use and update. See https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support for more info about how pip uses pyproject.toml to install build dependencies.

Sure, here’s an example, on Ubuntu 18.04 LTS, x86_64, with Python 3.8 and pip 20.2.3 in a fresh virtualenv.

I got my wheel, and some simple tests indicate it’s working for me, so thank you for all your hard work. All I wanted to point out was that it (also) may NOT be related to old pip.

howie@jubjubuntu-ng:~
▶ mkdir test-cv2

howie@jubjubuntu-ng:~
▶ cd test-cv2

howie@jubjubuntu-ng:~/test-cv2
▶ virtualenv -p python3.8 venv
Running virtualenv with interpreter /usr/bin/python3.8
Using base prefix '/usr'
/usr/lib/python3/dist-packages/virtualenv.py:1086: DeprecationWarning: the imp module is deprecated in favour of importlib; see the                     module's documentation for alternative uses
  import imp
New python executable in /home/howie/test-cv2/venv/bin/python3.8
Also creating executable in /home/howie/test-cv2/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

howie@jubjubuntu-ng:~/test-cv2
▶ source venv/bin/activate
(venv)
howie@jubjubuntu-ng:~/test-cv2
▶ pip -V
pip 20.2.3 from /home/howie/test-cv2/venv/lib/python3.8/site-packages/pip (python 3.8)
(venv)
howie@jubjubuntu-ng:~/test-cv2
▶ uname -a
Linux jubjubuntu-ng 5.4.0-47-generic #51~18.04.1-Ubuntu SMP Sat Sep 5 14:35:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
(venv)
howie@jubjubuntu-ng:~/test-cv2
▶ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
(venv)
howie@jubjubuntu-ng:~/test-cv2
▶ pip install --no-binary :all: opencv-python
Collecting opencv-python
  Using cached opencv-python-4.4.0.44.tar.gz (88.9 MB)
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /home/howie/test-cv2/venv/bin/python3.8 /home/howie/test-cv2/venv/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6ct04o7f/overlay --no-warn-script-location --no-binary :all: --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
    Using cached setuptools-50.3.0.zip (2.2 MB)
  Collecting wheel
    Using cached wheel-0.35.1.tar.gz (59 kB)
  Collecting scikit-build
    Using cached scikit-build-0.11.1.tar.gz (132 kB)
  Collecting cmake
    Using cached cmake-3.18.2.post1.tar.gz (28 kB)
      ERROR: Command errored out with exit status 1:
       command: /home/howie/test-cv2/venv/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-796_mmlu/cmake/setup.py'"'"'; __file__='"'"'/tmp/pip-install-796_mmlu/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-pip-egg-info-g7dav2e8
           cwd: /tmp/pip-install-796_mmlu/cmake/
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/tmp/pip-install-796_mmlu/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: /home/howie/test-cv2/venv/bin/python3.8 /home/howie/test-cv2/venv/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-6ct04o7f/overlay --no-warn-script-location --no-binary :all: --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.
(venv)
howie@jubjubuntu-ng:~/test-cv2                                                                                                                       ⍉
▶ pip install scikit-build
Collecting scikit-build
  Using cached scikit_build-0.11.1-py2.py3-none-any.whl (72 kB)
Requirement already satisfied: setuptools>=28.0.0; python_version >= "3" in ./venv/lib/python3.8/site-packages (from scikit-build) (50.3.0)
Requirement already satisfied: wheel>=0.29.0 in ./venv/lib/python3.8/site-packages (from scikit-build) (0.35.1)
Collecting distro
  Using cached distro-1.5.0-py2.py3-none-any.whl (18 kB)
Collecting packaging
  Using cached packaging-20.4-py2.py3-none-any.whl (37 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Installing collected packages: distro, pyparsing, six, packaging, scikit-build
Successfully installed distro-1.5.0 packaging-20.4 pyparsing-2.4.7 scikit-build-0.11.1 six-1.15.0
(venv)
howie@jubjubuntu-ng:~/test-cv2
▶ pip install --no-binary :all: opencv-python
Collecting opencv-python
  Using cached opencv-python-4.4.0.44.tar.gz (88.9 MB)
  Installing build dependencies ... -
  {build continues to completion}