在macOS Catalina上使用python 3.9在virtualenvironment中安装opencvpython时出错

2024-05-16 02:02:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在macOS Catalina的MacBook Pro上设置一个名为deeplearning的虚拟环境,用于深度学习项目:-)

deeplearning虚拟环境中,我确实pip install opencv-python但是这会引发一个错误,我不理解。。。我怎么修理它?我是不是忽略了什么

查看整个错误输出的最后一位,它似乎试图将不同的numpy版本与特定的python版本相匹配Python 3.9不在其中。这就是问题所在吗?我是否应该恢复到版本Python 3.8

我安装了python@3.9numpybrew

谢谢

砂光机

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: /Users/swvanderlaan/.virtualenvs/deeplearning/bin/python /Users/swvanderlaan/.virtualenvs/deeplearning/lib/python3.9/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-build-env-mudxxq4k/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 (4098 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

[I could not post everything due to the character limit.]

  ERROR: Command errored out with exit status 1: /Users/swvanderlaan/.virtualenvs/deeplearning/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-install-we6wxt_t/numpy/setup.py'"'"'; __file__='"'"'/private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-install-we6wxt_t/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 /private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-record-wdchzme9/install-record.txt --single-version-externally-managed --prefix /private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-build-env-mudxxq4k/overlay --compile --install-headers /private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-build-env-mudxxq4k/overlay/include/site/python3.9/numpy Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/swvanderlaan/.virtualenvs/deeplearning/bin/python /Users/swvanderlaan/.virtualenvs/deeplearning/lib/python3.9/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/kc/c5rw4cb94c1c149gsm2ygfc00000gn/T/pip-build-env-mudxxq4k/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.

和更新。这扩展到安装:scipyscikit-learnscikit-image-它们都依赖于numpy。它也与pip3 install numpy一起安装


Tags: installpipnobuildnumpyversionvarvirtualenvs
1条回答
网友
1楼 · 发布于 2024-05-16 02:02:37

问题是Python 3.9只是有几个漏洞,看起来没有可用于OpenCV的二进制软件包。所以pip正试图从源代码处编译它,这显然失败了,因为它有许多依赖项

我建议您现在就安装Python 3.8,并在几周/几个月内升级到Python 3.9,届时pip上的所有通用软件包都可用

相关问题 更多 >