add cairo package in the anaconda python distribution

前端 未结 2 809
情书的邮戳
情书的邮戳 2021-01-22 02:07

I am new to using the anaconda distribution for python, and I have trouble installing the cairo package. Note that I am using Mac OsX.

I ran the following command

相关标签:
2条回答
  • 2021-01-22 02:26

    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

    0 讨论(0)
  • 2021-01-22 02:46

    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.

    0 讨论(0)
提交回复
热议问题