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
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:
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.
Please help me.
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:
install "pydantic<2"