Skip to content

[agentic-rag-toolbox-cloudsql] Update default python version for uv init #2006

@gitsnead

Description

@gitsnead

Not sure if this is an issue with the Cloud Shell environment or a step that I missed in the codelab. You can see the state of my Cloud Shell environment when encountered the issue below.

$ update-alternatives --list python
update-alternatives: error: no alternatives for python
$ python --version
Python 3.12.3

When I start out with an empty directory and run uv init, it sets 3.12 in the .python-version file.

This works fine for the lab when running everything local on Cloud Shell. However, the build fails when I attempt to deploy the restaurant_agent service to Cloud Run with this command:

gcloud run deploy restaurant-agent \
  --source . \
  --region $REGION \
  --set-env-vars "TOOLBOX_URL=$TOOLBOX_URL,GOOGLE_CLOUD_PROJECT=$GOOGLE_CLOUD_PROJECT,GOOGLE_CLOUD_LOCATION=$GOOGLE_CLOUD_LOCATION,GOOGLE_GENAI_USE_VERTEXAI=TRUE" \
  --allow-unauthenticated \
  --quiet

I found this in Cloud Build log for that run:

Using Python version from /workspace/.python-version: 3.12
--
  | Failed to resolve version 3.12 for Python from region us-central1: failed to resolve version matching: 3.12 against [3.14.5 3.14.4 3.14.3 3.14.2 3.14.1 3.14.0 3.13.13 3.13.12 3.13.11 3.13.10 3.13.9 3.13.8 3.13.7 3.13.6 3.13.5 3.13.4 3.13.3 3.13.2 3.13.1 3.13.0]
  | Failed to resolve version 3.12 for Python from region us: failed to resolve version matching: 3.12 against [3.14.5 3.14.4 3.14.3 3.14.2 3.14.1 3.14.0 3.13.13 3.13.12 3.13.11 3.13.10 3.13.9 3.13.8 3.13.7 3.13.6 3.13.5 3.13.4 3.13.3 3.13.2 3.13.1 3.13.0]
  | --------------------------------------------------------------------------------
  | failed to build: (error ID: 1ff870e4):
  | invalid Python version specified: failed to resolve version matching: 3.12 against [3.14.5 3.14.4 3.14.3 3.14.2 3.14.1 3.14.0 3.13.13 3.13.12 3.13.11 3.13.10 3.13.9 3.13.8 3.13.7 3.13.6 3.13.5 3.13.4 3.13.3 3.13.2 3.13.1 3.13.0] . Version constraint "3.12" not satisfied by any available versions in Artifact Registry. You may need to use a different builder. Please check if the language version specified is supported. You can refer to https://cloud.google.com/docs/buildpacks/builders for a list of compatible runtime languages per builder
  | --------------------------------------------------------------------------------
  | Sorry your project couldn't be built.

I used these commands to upgrade the project to Python 3.14 which the docs said is a supported version for Cloud Build.

uv python upgrade 3.14
uv python update-shell

After restarting my shell as recommended, I was able to run all the local tests and build restaurant_agent after matching the python version in my Cloud Shell instance to the expected one for Cloud Build.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions