I'm using a single ARM-cortex-A7 platform build with buildroot, I want to use gemini api on it with python

Hi guys,I’m using a single ARM-cortex-A7 platform build with buildroot, I want to use gemini api on it with python, my platform has a python3.11 env,but when i install the python api ,there are some dependent that must use rust to compile, does any other method to install gemini api on my board?
here is the commandline:
pip install google.generativeai
Collecting google.generativeai
Collecting google-api-core (from google.generativeai)
Downloading google_api_core-2.19.0-py3-none-any.whl.metadata (2.7 kB)
Collecting google-api-python-client (from google.generativeai)
Downloading google_api_python_client-2.131.0-py2.py3-none-any.whl.metadata (6.7 kB)
Collecting google-auth>=2.15.0 (from google.generativeai)
Downloading google_auth-2.29.0-py2.py3-none-any.whl.metadata (4.7 kB)
Collecting protobuf (from google.generativeai)
Downloading protobuf-5.27.0-py3-none-any.whl.metadata (592 bytes)
Collecting pydantic (from google.generativeai)
Downloading pydantic-2.7.3-py3-none-any.whl.metadata (108 kB)
�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━ 109.0/109.0 kB 132.0 kB/s eta 0:00:00
Collecting tqdm (from google.generativeai)
Downloading tqdm-4.66.4-py3-none-any.whl.metadata (57 kB)
�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━�━ 57.6/57.6 kB 189.7 kB/s eta 0:00:00

error
error: subprocess-exited-with-error

�× pip subprocess to install build dependencies did not run successfully.
�× Getting requirements to build wheel did not run successfully.
�│ exit code: 1
�╰�─> [16 lines of output]
Error in sitecustomize; set PYTHONVERBOSE for traceback:
SyntaxError: invalid non-printable character U+000F (sitecustomize.py, line 1)
Traceback (most recent call last):
File “/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”, line 353, in
main()
File “/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”, line 335, in main
json_out[‘return_val’] = hook(**hook_input[‘kwargs’])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py”, line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib/python3.11/site-packages/setuptools/build_meta.py”, line 338, in get_requires_for_build_wheel
File “/usr/lib/python3.11/site-packages/setuptools/build_meta.py”, line 320, in _get_build_requires
File “/usr/lib/python3.11/site-packages/setuptools/build_meta.py”, line 335, in run_setup
File “”, line 21, in
ModuleNotFoundError: No module named ‘setuptools_rust’
[end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: subprocess-exited-with-error
  
  �× Getting requirements to build wheel did not run successfully.
  �│ exit code: 1
  �╰�─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  [end of output]

error: subprocess-exited-with-error

    �× Building wheel for maturin (pyproject.toml) did not run successfully.
    �│ exit code: 1
    �╰�─> [35 lines of output]
        /rusttmp/pip-build-env-4vdzt38y/overlay/lib/python3.11/site-packages/setuptools/config/_apply_pyprojecttoml.py:83: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (depe)
          corresp(dist, value, root_dir)
        running bdist_wheel
        running build
        running build_py
        creating build
        creating build/lib.linux-armv7l-cpython-311
        creating build/lib.linux-armv7l-cpython-311/maturin
        copying maturin/__init__.py -> build/lib.linux-armv7l-cpython-311/maturin
        copying maturin/import_hook.py -> build/lib.linux-armv7l-cpython-311/maturin
        copying maturin/__main__.py -> build/lib.linux-armv7l-cpython-311/maturin
        running egg_info
        creating maturin.egg-info
        writing maturin.egg-info/PKG-INFO
        writing dependency_links to maturin.egg-info/dependency_links.txt
        writing requirements to maturin.egg-info/requires.txt
        writing top-level names to maturin.egg-info/top_level.txt
        writing manifest file 'maturin.egg-info/SOURCES.txt'
        reading manifest file 'maturin.egg-info/SOURCES.txt'
        reading manifest template 'MANIFEST.in'
        warning: no files found matching '*.json' under directory 'src/python_interpreter'
        writing manifest file 'maturin.egg-info/SOURCES.txt'
        running build_ext
        running build_rust
        error: can't find Rust compiler
  
        If you are using an outdated pip version, it is possible a prebuilt wheel is available for this package but pip is not able to install from it. Installing from the wheel would avoid the need.
  
        To update pip, run:
  
            pip install --upgrade pip
  
        and then retry package installation.
  
        If you did intend to build this package from source, try installing a Rust compiler from your system package manager and ensure it is on the PATH during installation. Alternatively, rustup (.
        [end of output]

Welcome to the forum!

I don’t have a quick fix to solve the dependencies issue.

The Gemini API offers a REST interface. If nothing else helps, it is perfectly possible to create a pure-Python implementation of the API without any google code and dependencies required to support the Google code. import requests is all you really need to handle the API communication.

In practice, the overall API response time is dominated by the model response. In my opinion, there is an insignificant performance improvement in the perceived response time by using the Apache protobuf protocol, which generally causes a large dependency chain. Google themselves could have opted to provide a pure-Python implementation of the library.

thank you , i will use REST interface to test

1 Like

Definitely a bold move. It is however fun and rewarding. This part of the API is the easiest to start with REST Resource: models  |  Google AI for Developers  |  Google for Developers
The next harder part is the Files API, it was introduced relatively recently as an addition to the base API - REST Resource: files  |  Google AI for Developers  |  Google for Developers
That means you can get up and running initially without the Files part and add it later.