Trying to install openai in chaquopy in android studio but getting build failed

题意:"尝试在 Android Studio 的 Chaquopy 中安装 OpenAI,但构建失败。"

问题背景:

Pretty much title, tried to import openai in android studio to use their api for my android app but everytime I run the app I get the same build error

"基本如标题所述,尝试在 Android Studio 中导入 OpenAI 以在我的 Android 应用中使用他们的 API,但每次运行应用时都会遇到相同的构建错误。"

This is fragment of my module-level build.gradle:

复制代码
chaquopy {
    defaultConfig {
        pyc {
            src = false
        }
        pip {
            install "openai"
        }

        buildPython "C:\\Users\\Vladlen\\AppData\\Local\\Programs\\Python\\Python310\\python.exe"
    }

This is my Build Output:

Kotlin 复制代码
Cargo, the Rust package manager, is not installed or is not on PATH.
    This package requires Rust and Cargo to compile extensions. Install it through
    the system's package manager or via https://rustup.rs/
    
    Checking for Rust toolchain....
    ----------------------------------------
ERROR: Failed to install pydantic-core==2.16.3 from https://files.pythonhosted.org/packages/77/3f/65dbe5231946fe02b4e6ea92bc303d2462f45d299890fd5e8bfe4d1c3d66/pydantic_core-2.16.3.tar.gz#sha256=1cac689f80a3abab2d3c0048b29eea5751114054f032a941a32de4c852c59cad (from pydantic<3,>=1.9.0->openai).
For assistance, please raise an issue at https://github.com/chaquo/chaquopy/issues.
Chaquopy: Exit status 1



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateDebugPythonRequirements'.
> Process 'command 'C:\Users\Vladlen\AndroidStudioProjects\AIBook\app\build\python\env\debug\Scripts\python.exe'' finished with non-zero exit value 1 

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:generateDebugPythonRequirements'.

Caused by: com.chaquo.python.BuildPythonException: Process 'command 'C:\Users\Vladlen\AndroidStudioProjects\AIBook\app\build\python\env\debug\Scripts\python.exe'' finished with non-zero exit value 1 

To view full details in Android Studio:
* Click the 'Build: failed' caption to the left of this message.
* Then scroll up to see the full output.

问题解决:

Chaquopy doesn't support pydantic version 2 yet, but since openai is still compatible with version 1, you can work around it by adding this line to your pip block:

"Chaquopy 目前不支持 pydantic 版本 2,但由于 openai 仍与版本 1 兼容,您可以通过在您的 pip 块中添加以下行来解决此问题:"

bash 复制代码
install "pydantic<2"
相关推荐
Hello_Pyhx6 分钟前
VoiceStudio v0.5.6:从桌面生成到本地语音 API
ai·语音识别·克隆·声音
mmsx15 分钟前
Android 测绘计算工程化:七四参数、高程拟合与单位系统
android·kotlin
最强小杰30 分钟前
Claude Opus 4.8 调用一直报 529 怎么办?同样请求换旧模型却正常——附 429/529 双桶退避代码
ai·github
goehou1 小时前
LLM 结构化输出全解:从 Prompt 约束到 Schema 硬保证,三层实现怎么选
ai·llm·json·agent·教程·结构化输出
我是场2 小时前
我的NPI项目之-Touch的EE特性
android·arm开发
天空之城--2 小时前
Android一周动态:AI编程、Compose与车载生态新信号
android·flutter
?? Daisy3 小时前
ZCode 添加自定义模型:自定义供应商的字段与易错点(2026-09)
人工智能·ai·ai编程
恋猫de小郭3 小时前
Dart 4.0 要彻底移除 dart:mirrors,Augmentations 应该要来了
android·前端·flutter
奇牙coding4 小时前
GPT-5.5 API 报 401 但 GPT-5.4 正常怎么办?不是 Key 失效,是 Organization 头的强制校验变了
java·网络·gpt·ai
sbjdhjd5 小时前
智能体开始“动手”之后:OpenAI越权事件、Anthropic算力资本化与开放权重模型竞逐 | AI与SI行业日报整理(9月29日—10月6日)
大数据·人工智能·经验分享·笔记·ai·chatgpt·开源