简体   繁体   English

pip install pycairo 在 osx 上失败:“pkg-config”搜索路径问题

[英]pip install pycairo fails on osx: 'pkg-config' search path problems

I've been trying to install pycairo on a mac os x.我一直在尝试在 mac os x 上安装 pycairo。 I'm getting an error message,我收到一条错误消息,

Initially I was getting 'pkg-config' not found .最初我得到'pkg-config' not found After installing that through brew, I get Package cairo was not found in the pkg-config search path .通过 brew 安装后,我得到Package cairo was not found in the pkg-config search path In principle I could try to edit the search path, but since this is going through pip, I would have expected this to be all taken care of.原则上我可以尝试编辑搜索路径,但由于这是通过 pip 进行的,所以我希望这一切都会得到解决。 Is there a way to tell pip to put the stuff where pkg-config knows to look?有没有办法告诉 pip 把东西放在 pkg-config 知道的地方?

Here's the full message.这是完整的信息。

> pip install pycairo
Collecting pycairo
  Using cached https://files.pythonhosted.org/packages/48/20/5e83af98eb897935bf7dc39455e892ba866feebb9b7c3b392982866f9958/pycairo-1.18.1.tar.gz
Building wheels for collected packages: pycairo
  Building wheel for pycairo (setup.py) ... error
  ERROR: Complete output from command /Applications/anaconda/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/f2/bzrj46j11gzdk19j91tp1sq80000gq/T/pip-install-lahb8lq4/pycairo/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 /private/var/folders/f2/bzrj46j11gzdk19j91tp1sq80000gq/T/pip-wheel-scnvplas --python-tag cp36:
  ERROR: running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.7-x86_64-3.6
  creating build/lib.macosx-10.7-x86_64-3.6/cairo
  copying cairo/__init__.py -> build/lib.macosx-10.7-x86_64-3.6/cairo
  copying cairo/__init__.pyi -> build/lib.macosx-10.7-x86_64-3.6/cairo
  copying cairo/py.typed -> build/lib.macosx-10.7-x86_64-3.6/cairo
  running build_ext
  Package cairo was not found in the pkg-config search path.
  Perhaps you should add the directory containing `cairo.pc'
  to the PKG_CONFIG_PATH environment variable
  No package 'cairo' found
  Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.13.1']' returned non-zero exit status 1.
  ----------------------------------------
  ERROR: Failed building wheel for pycairo

I get the same error if I use pip to install an older version.如果我使用 pip 安装旧版本,我会得到同样的错误。

There is a similar question here: How can I fix the problem when installing pycairo on windows?这里有一个类似的问题: How can I fix the problem when installed pycairo on windows? , but it's related to Windows, and the error looks to be different to me (also I'm not satisfied by the answer). ,但它与 Windows 有关,并且错误看起来与我不同(我对答案也不满意)。

Any suggestion for how to fix this?关于如何解决这个问题的任何建议?

I ran into this issue too.我也遇到了这个问题。

I am using Q4OS(Debian), and do not have brew.我正在使用 Q4OS(Debian),并且没有 brew。

Here is these steps I manage to solve this issue.这是我设法解决此问题的这些步骤。

sudo apt-get update -y
sudo apt-get install -y pkg-config
sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev
sudo pip install pycairo

I could solve the issue with the help of the comments from the question.我可以在问题评论的帮助下解决问题。 In summary:总之:

brew install pkg-config
brew install cairo
pip install pycairo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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