1

I'm trying to install the WeasyPrint library on MacOS X (Sierra).

I already have Python 3 and Anaconda installed. The documentation suggests using Homebrew. Why is this necessary? Can Homebrew and Anaconda be used together in this case?

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
Brian
  • 715
  • 4
  • 16
  • 37
  • 1
    OS X only assuming? – dawg Apr 25 '17 at 23:51
  • yes, sorry, I will edit my comment – Brian Apr 26 '17 at 00:04
  • 2
    Entirely different things. Homebrew installs OS X apps in general -- it has Python-related packages, but tons of non-Python-related packages as well, and native OS X apps as well. Anaconda is a Python distribution; it does nothing but Python. – Charles Duffy Apr 26 '17 at 00:09
  • @CharlesDuffy is there a benefit to having both? If I am only trying to use it for Python, would Anaconda be the better option? – Brian Apr 26 '17 at 00:11
  • 1
    That said -- I'd argue that this is probably a better question for [SuperUser](https://superuser.com/) than StackOverflow. Homebrew, in particular, has *lots* of non-development-related uses. – Charles Duffy Apr 26 '17 at 00:12
  • 1
    If all you want is Python, there's no particular benefit to having both. If you have a use for non-Python-related modern UNIXy things (say, a modern bash 4 release, on the ability to install a database server with one command), then Homebrew (or, better IMHO, [MacPorts](http://macports.org/)) is liable to be of interest. – Charles Duffy Apr 26 '17 at 00:12
  • 1
    (much of the Homebrew-vs-MacPorts argument is around security models: MacPorts requires privilege escalation at package install and update time; Homebrew just weakens your system's security once up-front, `chown`ing `/usr/local/bin`, so it doesn't need privileges again later. Some people think escalating privileges habitually is bad so the Homebrew approach is better; I'm in the camp that says that weakening permissions is bad so the MacPorts approach is better). – Charles Duffy Apr 26 '17 at 00:16
  • @CharlesDuffy why would a Python Package require, or only able to be installed via Homebrew? Apologies if that should be a new question. – Brian Apr 26 '17 at 00:17
  • 1
    Typically having a dependency on some other library or component that Homebrew packages. It'd be more helpful to have a specific package at hand rather than being asked the question as a generality. – Charles Duffy Apr 26 '17 at 00:18
  • @CharlesDuffy great point - I updated my question again. The specific package is WeasyPrint – Brian Apr 26 '17 at 00:20
  • 1
    I've followed that up with some more heavy-handed edits that actually make the question specific enough to be answerable (and more arguably topical). – Charles Duffy Apr 26 '17 at 00:23

1 Answers1

2

The answer is in the dependency list. From http://weasyprint.readthedocs.io/en/latest/install.html:

WeasyPrint 0.36 depends on:

  • CPython 2.7 or ≥ 3.3
  • cairo [1]
  • Pango
  • CFFI ≥ 0.6
  • lxml ≥ 3.0
  • html5lib ≥ 0.999999999
  • cairocffi ≥ 0.5
  • tinycss2 ≥ 0.5
  • cssselect ≥ 0.6
  • CairoSVG ≥ 1.0.20
  • Pyphen ≥ 0.8
  • Optional: GDK-PixBuf [2]

Cairo, pango, and gdk-pixbuf are all native libraries written in C in association with GNOME and GDK; their native rendering layer is X11, making MacOS a feasible target, but by no means a native one; and none of the GDK, Cairo or Pango libraries ship with MacOS X.


  • Why is Homebrew necessary?

    Because it provides an easy way to install GDK-associated libraries on MacOS X.

  • Is it possible to use both Anaconda and Homebrew?

    Yes. It's definitely possible to build a Python module for Anaconda that uses libraries that have been installed by MacPorts.

  • Will installing WeasyPrint in Homebrew let me use that library in Anaconda with no further effort?

    No: Those are two different Python installations. Installing WeasyPrint in Homebrew will let you use it in your Homebrew-provided Python installation(s), and will make its library dependencies available on your system, but you'll still need to reinstall it (and any dependent Python wrappers) into your Anaconda Python installation.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • can you advise on [this](https://stackoverflow.com/questions/50657357/no-module-named-cairo-mac)? I have cairo installed thru `brew`, but [setting paths](https://superuser.com/questions/1328029/eclipse-unable-to-find-the-cairo-in-python-while-it-can-be-found-in-the-termin) on IDE wont solve the import error. I hope [link](https://stackoverflow.com/questions/1500866/how-to-install-pycairo-on-osx/30089130#30089130) saying that I may need to install python inside the cairo? virtual env of some sort is not the issue. This seems like how boost libraries are used on Xcode, only problem is Im unsure. – dia Jun 03 '18 at 03:48