Install pycairo in virtualenv

后端 未结 6 1400
梦毁少年i
梦毁少年i 2020-12-13 09:44

I\'ve tried to install pycairo in a virtualenv to use in a Django project. I\'ve ran the pip install pycairo==1.10.0 command which finds the packag

6条回答
  •  情深已故
    2020-12-13 10:12

    For anyone trying to use pycairo (for Python 2.7) in conjunction with Homebrew and virtualenv --no-site-packages ... this Worked For Me:

    1. brew install py2cairo

    2. Then, find the path where Homebrew installed it to, will be something like:

      ls -l /usr/local/lib/python2.7/site-packages/cairo/
      total 24
      lrwxr-xr-x  1 anentropic  admin   80 10 Jun 14:26 __init__.py -> ../../../../Cellar/py2cairo/1.10.0/lib/python2.7/site-packages/cairo/__init__.py
      lrwxr-xr-x  1 anentropic  admin   78 10 Jun 14:26 _cairo.so -> ../../../../Cellar/py2cairo/1.10.0/lib/python2.7/site-packages/cairo/_cairo.so
      
    3. You want to find the path at the base of those symlinks, something like:
      /usr/local/Cellar/py2cairo/1.10.0/lib/python2.7/site-packages

    4. Then create a .pth file in your virtualenv site packages:
      echo "/usr/local/Cellar/py2cairo/1.10.0/lib/python2.7/site-packages" > venv/lib/python2.7/site-packages/cairo.pth

    (may want to deactivate and re-activate your virtualenv for good luck, not sure)

提交回复
热议问题