安装 OpenCV 失败,因为它找不到“skbuild"; [英] Installing OpenCV fails because it cannot find "skbuild"
问题描述
我有一个 docker 镜像,我需要在其中安装 openCV,从昨天开始它开始失败,因为它找不到skbuild"模块:
第 12/24 步:运行 pip install opencv-python opencv-contrib-python--->在 a0f746a23aed 中运行收集opencv-python下载 https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.MB.tar.gz命令 python setup.py egg_info 的完整输出:回溯(最近一次调用最后一次):文件<string>",第 1 行,在 <module>文件/tmp/pip-build-cciracwm/opencv-python/setup.py",第 9 行,在 <module> 中.导入 skbuildModuleNotFoundError: 没有名为skbuild"的模块
在主机上我也找不到那个模块,pip search
要么什么都不返回,要么返回一个服务器错误:
sudo pip3 search skbuild警告:目录/home/ali/.cache/pip"或其父目录不属于当前用户或不可写.缓存已被禁用.检查该目录的权限和所有者.如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志.错误:异常:回溯(最近一次调用最后一次):文件/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py",第216行,在_mainstatus = self.run(options, args)文件/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/search.py",第60行,运行中pypi_hits = self.search(查询,选项)文件/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/search.py",第80行,在搜索中hits = pypi.search({'name': query, 'summary': query}, 'or')文件/usr/lib/python3.6/xmlrpc/client.py",第 1112 行,在 __call__ 中返回 self.__send(self.__name, args)文件/usr/lib/python3.6/xmlrpc/client.py",第 1452 行,在 __request 中详细=自我.__详细文件/usr/local/lib/python3.6/dist-packages/pip/_internal/network/xmlrpc.py",第45行,请求返回 self.parse_response(response.raw)文件/usr/lib/python3.6/xmlrpc/client.py",第 1342 行,在 parse_response返回 u.close()文件/usr/lib/python3.6/xmlrpc/client.py",第 656 行,关闭引发错误(**self._stack[0])xmlrpc.client.Fault: <Fault -32403: '服务器错误;服务不可用'>
这是因为他们的服务器有问题还是与我的点有关?
更新
我在不同的 python 和 pip 版本上进行了尝试,python 版本 3.6 和 3.7 以及 pip 版本 19.12 和 20.2.2 和 9.0.1(内部图像).
更新 2
我在安装 opencv 之前添加了 pip install scikit-build
一步,但我遇到了另一个与 cmake 相关的错误:
第 12/25 步:运行 pip install scikit-build--->在 afe0c5c0fca0 中运行收集 scikit-build下载 https://files.pythonhosted.org/packages/78/c9/7c2c7397ea64e36ebb292446896edcdecbb8c1aa6b9a1a32f6f67984c3df/scikit_build-0.11.1-py2.py3-whlnone-py2.py3-none-收集包装(来自 scikit-build)下载 https://files.pythonhosted.org/packages/46/19/c5ab91b1b05cfe63cccd5cfc971db9214c6dd6ced54e33c30d5af1d2bc43/packaging-20.4-py2.py3-none-any.whl要求已经满足:/usr/lib/python3/dist-packages中的wheel>=0.29.0(来自scikit-build)收集发行版(来自 scikit-build)下载 https://files.pythonhosted.org/packages/25/b7/b3c4270a11414cb22c6352ebc7a83aaa3712043be29daa05018fd5a5c956/distro-1.5.0-py2.py3-whlnone-已经满足要求:setuptools>=28.0.0;python_version >=3"在/usr/lib/python3/dist-packages(来自 scikit-build)已满足要求:/usr/lib/python3/dist-packages 中有 6 个(来自 Packaging->scikit-build)收集pyparsing>=2.0.2(来自打包->scikit-build)下载 https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.any7whl-p安装收集到的包:pyparsing、packaging、distro、scikit-build成功安装distro-1.5.0 Packaging-20.4 pyparsing-2.4.7 scikit-build-0.11.1删除中间容器 afe0c5c0fca0--->533658ddf26d步骤 13/25:运行 pip install opencv-python opencv-contrib-python--->运行在 0f2c03bc042a收集opencv-python下载 https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.MB.tar.gz收集 opencv-contrib-python下载https://files.pythonhosted.org/packages/48/98/05bd8e00c71b66c4e7847cc051cac404191d904df58b51a7dcc3767ff747/opencv_contrib_python-4.2.0.34-cp37-cp37m-manylinux1_x86_64.whl(34.2MB)收集 numpy>=1.14.5(来自 opencv-python)下载 https://files.pythonhosted.org/packages/3d/d1/90cd7e0b27ee86d77f5386d38b74520486100286d50772377791b6ef22ff/numpy-1.19.1-cp37-cp3614mx.1.19.1-cp37-cp3614mx48-cp3614mx.为收集的包构建轮子:opencv-python为 opencv-python 运行 setup.py bdist_wheel:开始为 opencv-python 运行 setup.py bdist_wheel:完成状态错误"命令/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-w49xv99a/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/tmpycj03zlwpip-wheel- --python-tag cp37:/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'警告.警告(味精)回溯(最近一次调用最后一次):文件/usr/local/lib/python3.7/dist-packages/skbuild/setuptools_wrap.py",第 560 行,在 setup 中cmkr = cmaker.CMaker(cmake_executable)文件/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py",第 95 行,在 __init__ 中self.cmake_version = get_cmake_version(self.cmake_executable)文件/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py",第82行,get_cmake_version"CMake 安装出现问题,正在中止构建.CMake 可执行文件是 %s"% cmake_executable)CMake 安装出现问题,正在中止构建.CMake 可执行文件是 cmake---------------------------opencv-python 的构建轮失败为 opencv-python 运行 setup.py clean无法构建 opencv-python安装收集到的包:numpy、opencv-python、opencv-contrib-python找到现有安装:numpy 1.13.3不在/usr/lib/python3/dist-packages、外部环境/usr 卸载 numpy为 opencv-python 运行 setup.py install:开始为 opencv-python 运行 setup.py 安装:完成状态错误"命令/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-w49xv99a/opencv-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))"安装 --record/tmp/pip-maky1uyw-record/install-record.txt --single-version-externally-managed --compile:/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'警告.警告(味精)回溯(最近一次调用最后一次):文件/usr/local/lib/python3.7/dist-packages/skbuild/setuptools_wrap.py",第 560 行,在 setup 中cmkr = cmaker.CMaker(cmake_executable)文件/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py",第 95 行,在 __init__ 中self.cmake_version = get_cmake_version(self.cmake_executable)文件/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py",第82行,get_cmake_version"CMake 安装出现问题,正在中止构建.CMake 可执行文件是 %s"% cmake_executable)CMake 安装出现问题,正在中止构建.CMake 可执行文件是 cmake
如果你阅读了 opencv-python
PyPI 中的包常见问题,它清楚地为这个特定问题提供了答案:您必须运行 pip install --upgrade pip
.之后用 pip -V
检查 pip
版本.
这是因为您的 pip
太旧,无法理解新的 manylinux2014
包格式并尝试从源代码编译.这也会失败,因为 pip
太老了,无法理解如何使用 pyproject.toml
来安装构建依赖项,例如 scikit-build
.>
我发现的另一个问题是您同时安装了 opencv-python
和 opencv-contrib-python
.你不应该这样做.它也在包的 PyPI 页面中进行了解释.很可能您应该只使用 opencv-contrib-python-headless
包,因为您使用的是 Docker,我假设您没有使用 OpenCV 的 GUI 功能.
I have a docker image that I need to install openCV in it and from yesterday it started to fail because it cannot find the "skbuild" module:
Step 12/24 : RUN pip install opencv-python opencv-contrib-python
---> Running in a0f746a23aed
Collecting opencv-python
Downloading https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz (88.9MB)
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-cciracwm/opencv-python/setup.py", line 9, in <module>
import skbuild
ModuleNotFoundError: No module named 'skbuild'
And on the host also I cannot find that module and pip search
is either return nothing or returns a server error:
sudo pip3 search skbuild
WARNING: The directory '/home/ali/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/search.py", line 60, in run
pypi_hits = self.search(query, options)
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/search.py", line 80, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "/usr/lib/python3.6/xmlrpc/client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "/usr/lib/python3.6/xmlrpc/client.py", line 1452, in __request
verbose=self.__verbose
File "/usr/local/lib/python3.6/dist-packages/pip/_internal/network/xmlrpc.py", line 45, in request
return self.parse_response(response.raw)
File "/usr/lib/python3.6/xmlrpc/client.py", line 1342, in parse_response
return u.close()
File "/usr/lib/python3.6/xmlrpc/client.py", line 656, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: <Fault -32403: 'server error; service unavailable'>
Is this because their server has some problems or it is related to my pip?
Update
I tried it on different python and pip versions, python versions 3.6 and 3.7 and pip version 19.12 and 20.2.2 and 9.0.1 (the one inside image).
Update 2
I added pip install scikit-build
one step before opencv installation but I get another error related to cmake:
Step 12/25 : RUN pip install scikit-build
---> Running in afe0c5c0fca0
Collecting scikit-build
Downloading https://files.pythonhosted.org/packages/78/c9/7c2c7397ea64e36ebb292446896edcdecbb8c1aa6b9a1a32f6f67984c3df/scikit_build-0.11.1-py2.py3-none-any.whl (72kB)
Collecting packaging (from scikit-build)
Downloading https://files.pythonhosted.org/packages/46/19/c5ab91b1b05cfe63cccd5cfc971db9214c6dd6ced54e33c30d5af1d2bc43/packaging-20.4-py2.py3-none-any.whl
Requirement already satisfied: wheel>=0.29.0 in /usr/lib/python3/dist-packages (from scikit-build)
Collecting distro (from scikit-build)
Downloading https://files.pythonhosted.org/packages/25/b7/b3c4270a11414cb22c6352ebc7a83aaa3712043be29daa05018fd5a5c956/distro-1.5.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=28.0.0; python_version >= "3" in /usr/lib/python3/dist-packages (from scikit-build)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from packaging->scikit-build)
Collecting pyparsing>=2.0.2 (from packaging->scikit-build)
Downloading https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl (67kB)
Installing collected packages: pyparsing, packaging, distro, scikit-build
Successfully installed distro-1.5.0 packaging-20.4 pyparsing-2.4.7 scikit-build-0.11.1
Removing intermediate container afe0c5c0fca0
---> 533658ddf26d
Step 13/25 : RUN pip install opencv-python opencv-contrib-python
---> Running in 0f2c03bc042a
Collecting opencv-python
Downloading https://files.pythonhosted.org/packages/77/f5/49f034f8d109efcf9b7e98fbc051878b83b2f02a1c73f92bbd37f317288e/opencv-python-4.4.0.42.tar.gz (88.9MB)
Collecting opencv-contrib-python
Downloading https://files.pythonhosted.org/packages/48/98/05bd8e00c71b66c4e7847cc051cac404191d904df58b51a7dcc3767ff747/opencv_contrib_python-4.2.0.34-cp37-cp37m-manylinux1_x86_64.whl (34.2MB)
Collecting numpy>=1.14.5 (from opencv-python)
Downloading https://files.pythonhosted.org/packages/3d/d1/90cd7e0b27ee86d77f5386d38b74520486100286d50772377791b6ef22ff/numpy-1.19.1-cp37-cp37m-manylinux1_x86_64.whl (13.4MB)
Building wheels for collected packages: opencv-python
Running setup.py bdist_wheel for opencv-python: started
Running setup.py bdist_wheel for opencv-python: finished with status 'error'
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-w49xv99a/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/tmpycj03zlwpip-wheel- --python-tag cp37:
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/usr/local/lib/python3.7/dist-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: numpy, opencv-python, opencv-contrib-python
Found existing installation: numpy 1.13.3
Not uninstalling numpy at /usr/lib/python3/dist-packages, outside environment /usr
Running setup.py install for opencv-python: started
Running setup.py install for opencv-python: finished with status 'error'
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-w49xv99a/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-maky1uyw-record/install-record.txt --single-version-externally-managed --compile:
/usr/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/skbuild/setuptools_wrap.py", line 560, in setup
cmkr = cmaker.CMaker(cmake_executable)
File "/usr/local/lib/python3.7/dist-packages/skbuild/cmaker.py", line 95, in __init__
self.cmake_version = get_cmake_version(self.cmake_executable)
File "/usr/local/lib/python3.7/dist-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
If you read the opencv-python
package FAQ in PyPI, it clearly provides an answer for this specific issue: you must run pip install --upgrade pip
. Check pip
version afterwards with pip -V
.
This is because your pip
is too old to understand the new manylinux2014
package format and tries to compile from source. That will also fail because pip
is too old to understand how to use pyproject.toml
to install build dependencies such as scikit-build
.
Another issue I'm spotting is that you install both opencv-python
and opencv-contrib-python
. You should not do this. It's also explained in the PyPI page of the packages. Most likely you should be using just opencv-contrib-python-headless
package since you are using Docker and I assume you do not use the GUI functionalities of OpenCV.
这篇关于安装 OpenCV 失败,因为它找不到“skbuild";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!