简体   繁体   中英

Can't install OpenCV python3.8

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

Try to upgrade your pip with

pip install --upgrade pip

and then run the

pip install opencv-python

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

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
...

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

Try this:

pip3 install cmake --user

pip3 install --upgrade pip --user

pip3 install opencv-python --user

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM