# macos python运行md2pdf、weasyprint时报错 cannot load library 'libgobject-2.0-0'

**URL:** <https://forum.beginner.center/t/topic/2348>\
**Category:** 🛠工具与编程\
**Tags:** macos, python\
**Created:** [2025 年11 月 3 日 02:51 UTC](https://forum.beginner.center/t/topic/2348 "2025-11-03T02:51:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

作者： ![doggie](https://forum.beginner.center/user_avatar/forum.beginner.center/doggie/32/550_2.png) [@doggie](https://forum.beginner.center/u/doggie)\
发布日期： [2025 年11 月 3 日 02:51 UTC](https://forum.beginner.center/t/topic/2348/1 "2025-11-03T02:51:50Z")

</div>

# 报错

[python 运行md2pdf、来把markdown、WeasyPrint转换为pdf](https://forum.beginner.center/t/topic/2347)时，提示找不到`libgobject-2.0-0`

```auto
OSError: cannot load library 'libgobject-2.0-0': dlopen(libgobject-2.0-0, 0x0002): tried: 'libgobject-2.0-0' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgobject-2.0-0' (no such file), '/usr/lib/libgobject-2.0-0' (no such file, not in dyld cache), 'libgobject-2.0-0' (no such file).  
Additionally, ctypes.util.find_library() did not manage to locate a library called 'libgobject-2.0-0'

```

虽然已经通过homebrew安装了pandoc、pango、libffi等包，但还是没用

最后通过软链接，把homebrew安装的相关依赖连接到本地去

```auto
sudo ln -s /opt/homebrew/lib/libgobject-2.0.0.dylib /usr/local/lib/libgobject-2.0-0
sudo ln -s /opt/homebrew/lib/libpango-1.0.0.dylib /usr/local/lib/libpango-1.0-0
sudo ln -s /opt/homebrew/lib/libharfbuzz.0.dylib /usr/local/lib/libharfbuzz-0
sudo ln -s /opt/homebrew/lib/libfontconfig.1.dylib /usr/local/lib/libfontconfig-1
sudo ln -s /opt/homebrew/lib/libpangoft2-1.0.dylib /usr/local/lib/libpangoft2-1.0-0

```

# 参考

- [https://stackoverflow.com/questions/69097224/gobject-2-0-0-not-able-to-load-on-macbook](https://stackoverflow.com/questions/69097224/gobject-2-0-0-not-able-to-load-on-macbook)
- [WeasyPrint项目部署中libgobject依赖问题的解决方案 - AtomGit | GitCode博客](https://blog.gitcode.com/bd69d82da18240dcd4f7de37c8c89a53.html)
