首页 > 解决方案 > 执行错误:pip install opencv-python

问题描述

因此,我尝试在 Windows 10 中使用我的管理员命令提示符安装 OpenCV-Python,而我的 python 版本是 3.9,并且 pip 已完全更新。这是我在尝试执行后遇到的(大量)错误pip install opencv-python

这就是发生的事情:

C:\WINDOWS\system32>pip install 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: 'C:\Users\inbet\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.240.0_x64__qbz5n2kfra8p0\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\inbet\AppData\Local\Temp\pip-build-env-prbqcb63\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 (310 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.1-py3-none-any.whl (785 kB)
  Collecting wheel
    Using cached wheel-0.35.1-py2.py3-none-any.whl (33 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.2.post1-py3-none-win_amd64.whl (34.7 MB)
  Collecting pip
    Using cached pip-20.2.3-py2.py3-none-any.whl (1.5 MB)
  Collecting numpy==1.17.3
    Using cached numpy-1.17.3.zip (6.4 MB)
  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 six
    Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
  Collecting pyparsing>=2.0.2
    Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
  Using legacy 'setup.py install' for numpy, since package 'wheel' is not installed.
  Installing collected packages: setuptools, wheel, distro, six, pyparsing, packaging, scikit-build, cmake, pip, numpy
      Running setup.py install for numpy: started
      Running setup.py install for numpy: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: 'C:\Users\inbet\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\inbet\\AppData\\Local\\Temp\\pip-install-dqkz6qyf\\numpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\inbet\\AppData\\Local\\Temp\\pip-install-dqkz6qyf\\numpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\inbet\AppData\Local\Temp\pip-record-zko205u_\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\inbet\AppData\Local\Temp\pip-build-env-prbqcb63\overlay' --compile --install-headers 'C:\Users\inbet\AppData\Local\Temp\pip-build-env-prbqcb63\overlay\Include\numpy'
           cwd: C:\Users\inbet\AppData\Local\Temp\pip-install-dqkz6qyf\numpy\
      Complete output (277 lines):
      Running from numpy source directory.

之后还有很多,但我无法完整发布错误,因为它说“看起来你的帖子主要是代码。请添加更多细节”

我的直觉是,所有这一切都发生了,因为我的 python 目录不在其中,C:\ProgramFiles\Python或者可能与我通过 Windows 应用商店安装 python 的事实有关。

我知道它有很多代码,我才刚刚开始涉足这个领域,因为我正在尝试创建一个脚本,该脚本将抓取 eBay 缩略图并从输入了搜索字词的起始页面下载图像,当且仅当这些图像包含数字。因此,我为什么要尝试安装 OpenCV。

任何帮助将不胜感激。我最后一次编写任何代码是在我 12 岁的时候玩 Never Winter Nights,它使用了 C+ 之类的东西,所以我通常知道我在引擎盖下的方式,但对 python 特定命令完全陌生,我希望我正在尝试这个小项目将教我一些关于 python 的有用信息,并自动执行整个“大海捞针”搜索带有数字的图像。

干杯

标签: pythonpython-3.xnumpyopencvpip

解决方案


opencv 需要在此之前安装轮子


推荐阅读