add cairo package in the anaconda python distribution

吃可爱长大的小学妹 提交于 2019-12-02 00:17:27

I just installed py2cairo under Anaconda, using autotools, and it seems to work fine. The alternate 'waf' install was problematic, in that it picked up another version of python installed on my system (not the one in my PATH), and while I was able to build py2cairo, anaconda python didn't like it.

Basic instructions for building from autotools are here. I assume that Anaconda is installed under /anaconda, and that the py2cairo tarball untars to py2cairo-1.10.1. Also, you will need autotools (available from Macports, for example).

  1. Untar py2cairo tarball under /anaconda/pkgs
  2. In pkgs/py2cairo-1.10.0, create a 'bootstrap' file containing the following commands :

    libtoolize --force
    aclocal
    autoheader
    automake --force-missing --add-missing
    autoconf
    

(autotools experts would be able to clarify the steps above. The problem I ran into was that running "configure" out of the box led to an error about "install.sh", etc. not being found. Re-creating the configure scripts with the above fixes this problem.)

  1. Run bootstrap

    pkgs/py2cairo-1.10.1 % sudo sh bootstrap
    

Alternatively, you could just run the bootstrap commands from the command line.

  1. Then, run 'configure', setting the prefix to your python installation :

    pkgs/py2cairo-1.10.1 % sudo configure --prefix=/anaconda
    
  2. Make and install as usual :

    pkgs/py2cairo-1.10.1 % sudo gmake
    pkgs/py2cairo-1.10.1 % sudo gmake install
    
  3. Test your installation with :

    % /anaconda/bin/python -c "import cairo"
    

I am not a Python export, and so welcome any comments on the above.

Have you installed a package with Python bindings, such as PyCairo och cairocffi? If you haven't you won't be able to interact with Cairo from Python.

I've just spent way too much time trying to get this to work myself with Anaconda on my Mac. I couldn't get PyCairo to work at all, but I managed to get cairocffi installed and working through pip after a bit of fiddling.

If import cairocffi doesn't work and gives you an error message that ends with

OSError: cannot load library libcairo.so.2: dlopen(libcairo.so.2, 2): image not found

try export DYLD_FALLBACK_LIBRARY_PATH=$DYLD_FALLBACK_LIBRARY_PATH:/Users/your_username/anaconda/lib/ or whatever your Anaconda path is at the command line.

Also see https://github.com/SimonSapin/cairocffi/issues/29

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!