# live2d-py
**Repository Path**: Arkueid/live2d-py
## Basic Information
- **Project Name**: live2d-py
- **Description**: Live2D Library for Python (C++ impl): Supports model loading, lip-sync, basic face rigging, and precise click test.
- **Primary Language**: C++
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-11-24
- **Last Updated**: 2026-11-24
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
live2d-py
English README
**注意:本仓库不包含 Live2D Cubism Core(受许可限制),源码编译时需自行从 [Live2D官网](https://www.live2d.com/en/sdk/download/native/) 下载;Framework 由 fork 仓库 [Arkueid/CubismNativeFramework](https://github.com/Arkueid/CubismNativeFramework) 作为 submodule 维护。**
使用 Python 直接加载和操作 Live2D 模型,不通过 Web Engine 等间接手段进行渲染。
基于 Python C Extension 对 Live2D Native SDK (C++) 进行了封装。理论上,只要配置好 OpenGL(默认)或 Vulkan(可选)上下文,即可在 Python 中将 live2d 绘制在任何基于 OpenGL / Vulkan 的窗口。
代码使用示例:[examples](./examples/)
详细使用文档:[Wiki](https://github.com/EasyLive2D/live2d-py/wiki)
修改和开发:[CONTRIBUTING](./CONTRIBUTING.md)
## 兼容UI库
理论上兼容所有能使用 OpenGL 进行绘制的UI库: Pygame / PyQt5 / PySide2 / PySide6 / GLFW / pyopengltk / FreeGlut / Qfluentwidgets ...;另提供可选的 Vulkan 渲染后端(默认不开启,需 `vkInit` 显式初始化)。
## 支持功能
* 加载模型:**Cubism 2.1** 和 **Cubism 3.0** 及以上版本
* 视线跟踪
* 点击交互
* 动作播放回调
* 口型同步
* 模型各部分参数控制
* 各部件透明度控制
* 精确到部件的点击检测
* OpenGL / Vulkan 双渲染后端(Vulkan 可选,默认 OpenGL)
## 兼容性
### Cubism Live2D 版本
| `live2d-py` | 支持的live2d模型 | 实现 |
|--------------|---------------------|-------------------------|
| `live2d.Model` | Cubism 2.1 以及更早的版本 / Cubism 3.0 及以上版本 | C++ 实现:V2 为 Cubism 2.X WebSDK 移植,V3 为 CubismNativeSDK 封装 |
纯 Python 版 `live2d.v2` 已移除,V2 模型统一由 C++ 实现提供。
### Python 版本及平台
:white_check_mark:: 可用, 支持, 已通过
:question:: 尚未测试
:construction:, :x:: 编译期问题或平台兼容性问题待解决
| Platform | Python Version | `live2d.Model` (Cubism 2.1 + 3.0+) | PyPI |
|----------|---------------|------------------------------------|------|
| macOS arm64 | `>=3.11` |:white_check_mark:|:white_check_mark:|
| Windows x64 | `>=3.11` |:white_check_mark:|:white_check_mark:|
| Linux x64 | `>=3.11` |:white_check_mark:|:white_check_mark:|
注:
* Cubism 2.X 导出的模型:文件名格式常为 `XXX.moc`,`XXX.model.json`,`XXX.mtn`
* Cubism 3.0 及以上导出的模型:文件名格式常为 `XXX.moc3`,`XXX.model3.json`, `XXX.motion3.json`
## 使用说明
1. 在 [Release](https://github.com/EasyLive2D/live2d-py/releases/latest) 中下载对应版本的 `whl` 文件并安装(推荐)
```shell
pip install live2d_py-0.X.X-cpXXX-cpXXX-win_amd64.whl
```
2. 通过 [PyPI](https://pypi.org/project/live2d-py/) 安装
```shell
pip install live2d-py
```
3. 从源码构建,参考 [安装#源码构建](https://github.com/EasyLive2D/live2d-py/wiki/%E5%AE%89%E8%A3%85#%E6%BA%90%E7%A0%81%E6%9E%84%E5%BB%BA)
## 示例
### 简易面捕
源码见 [main_facial_bind.py](./examples/main_facial_bind.py)

### 基于 live2d-py C 模块及 Qt 开发的 Live2DViewer

### 多模型加载
源码见 [main_glfw_four_model.py](./examples/main_glfw_four_model.py)

### 添加背景
源码见 [main_pygame_background.py](./examples/main_pygame_background.py)

### 模型变换 & 口型同步音频 & 点击测试
源码见 [main_glfw.py](./examples/main_glfw.py)

### 模型整体透明度示例
源码见 [main_pyqt5_canvas_opacity.py](./examples/main_pyqt5_canvas_opacity.py)

## 鸣谢
特别感谢以下用户为本项目提供的帮助和支持: [96bearli], [Ovizro], [AnyaCoder], [jahtim], [Honghe], [RobertMeow], [LUORANCHENG], [TinyKiecoo], [Barracuda72], [GuangChen2333], [makabakadot], [thynetruly], [mastwet], [KyvYang], @Mozilla88, @CooperWang0912, @minghf85
[96bearli]: https://github.com/96bearli
[Ovizro]: https://github.com/Ovizro
[AnyaCoder]: https://github.com/AnyaCoder
[jahtim]: https://github.com/jahtim
[Honghe]: https://github.com/Honghe
[RobertMeow]: https://github.com/RobertMeow
[LUORANCHENG]: https://github.com/LUORANCHENG
[TinyKiecoo]: https://github.com/TinyKiecoo
[Barracuda72]: https://github.com/Barracuda72
[GuangChen2333]: https://github.com/GuangChen2333
[makabakadot]: https://github.com/makabakadot
[thynetruly]: https://github.com/thynetruly
[mastwet]: https://github.com/mastwet
[KyvYang]: https://github.com/kyv001
非常感谢以下项目及其贡献者们的帮助:
[CubismNativeSamples](https://github.com/Live2D/CubismNativeSamples) (`live2d.v3`)
[Cubism2 Web SDK](https://github.com/dylanNew/live2d) (`live2d.v2`)
[de4js](https://github.com/lelinhtinh/de4js)(`JavaScript` 反混淆工具)
[JsConvert](https://github.com/JonBoynton/JSConvert) (`Javascript` 转 `Python` 工具)
[D2Evil](https://github.com/UlyssesWu/D2Evil) (`moc` 文件分析)
[facial-landmarks-for-cubism](https://github.com/adrianiainlam/facial-landmarks-for-cubism) (面捕参考)
[nlohmann/json](https://github.com/nlohmann/json) (v2cpp)
Live2D 模型:
* [Cubism 官方样例数据](https://www.live2d.com/en/learn/sample/)
* [雅萌工作室](https://yameng.remoon.cn/studio/live2d-f/1)
* [live2d-models](https://github.com/Eikanya/Live2d-model)
* [【虚拟主播模型】 宁宁vup化!](https://www.bilibili.com/video/BV1s7411d7y9)