WeasyPrint Python module not found

219 views Asked by At

I installed WeasyPrint on MacOS Ventura 13.4.1 using Homebrew. It seems to have installed properly,

which weasyprint

\usr\local\weasyprint

When I try to load the Python module however, I get the error,

python3 weasytest.py
...
ModuleNotFoundError: No module named 'weasyprint'

Some clues:

  • I'm using Python 3.11.6
  • Python is looking for modules in the following directories,
python3 -m site                                                                               
sys.path = [  '/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python311.zip',
    '/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11',
    '/usr/local/Cellar/[email protected]/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/lib-dynload',
    '/usr/local/lib/python3.11/site-packages',
    '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages',
]
  • Homebrew looks to have placed the python module in /usr/local/Cellar/weasyprint/60.1_1/libexec/lib/python3.12/site-packages/weasyprint

I can copy the module and a few of the dependencies (e.g. cssselect2, html5lib, pyphen) to one of the places that Python checks, but then eventually I get a missing module that isn't in the Cellar directory (specifically fontTools). I've tried upgrading brew, as well as running brew doctor and cleanup. Is there a missing link somewhere that I need to create?

0

There are 0 answers