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

2023-05-16

执行pip3 install opencv-python出现

Collecting opencv-python
  Using cached https://files.pythonhosted.org/packages/01/9b/be08992293fb21faf35ab98e06924d7407fcfca89d89c5de65442631556a/opencv-python-4.5.3.56.tar.gz
Collecting numpy>=1.13.3 (from opencv-python)
  Using cached https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl
Building wheels for collected packages: opencv-python
  Running setup.py bdist_wheel for opencv-python ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pngogcn6/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/tmpqrjtuw_5pip-wheel- --python-tag cp36:
  Traceback (most recent call last):
    File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
      cmkr = cmaker.CMaker(cmake_executable)
    File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
      self.cmake_version = get_cmake_version(self.cmake_executable)
    File "/home/sunjiadong/.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: numpy, opencv-python
  Running setup.py install for opencv-python ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pngogcn6/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-l1rn4gz_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    Traceback (most recent call last):
      File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/setuptools_wrap.py", line 560, in setup
        cmkr = cmaker.CMaker(cmake_executable)
      File "/home/sunjiadong/.local/lib/python3.6/site-packages/skbuild/cmaker.py", line 95, in __init__
        self.cmake_version = get_cmake_version(self.cmake_executable)
      File "/home/sunjiadong/.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 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-pngogcn6/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-l1rn4gz_-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-pngogcn6/opencv-python/

原因:pip版本低

sudo pip3 install --upgrade pip 

升级pip

然后重新执行执行pip3 install opencv-python

安装好后ubuntu中查看opencv的版本

python3 
import cv2
cv2.__version__

Question2

Traceback (most recent call last):
  File "/usr/bin/pip3", line 15, in <module>
    sys.exit(main())
  File "/home/rikirobot/.local/lib/python3.5/site-packages/pip/__init__.py", line 12, in main
    from pip._internal.utils.entrypoints import _wrapper
  File "/home/rikirobot/.local/lib/python3.5/site-packages/pip/_internal/utils/entrypoints.py", line 4, in <module>
    from pip._internal.cli.main import main
  File "/home/rikirobot/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 58
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Solution

curl -fsSL -o- https://bootstrap.pypa.io/pip/3.5/get-pip.py | python3.5

▲ubuntu安装opencv

sudo apt install cmake
pip install scikit-build

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config

安装
pip3 install opencv-python -i https://pypi.douban.com/simple --trust -host=pypi.douban.com
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Problem with the CMake installation, aborting build. CMake executable is cmake 的相关文章

随机推荐