agent-starter-pack setup-cicd FileNotFoundError: [WinError 2] The system cannot find the file specified
I'm getting the error: FileNotFoundError: [WinError 2] The system cannot find the file specified when running agent-starter-pack setup-cicd on Windows.
It fails at:
Running command: gcloud services list --project=agent-project-one --filter=config.name:secretmanager.googleapis.com --format=json
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\aldo\.local\bin\agent-starter-pack.exe\__main__.py", line 7, in <module>
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\click\core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\click\core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\click\core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\click\core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\click\core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\backoff\_sync.py", line 105, in retry
ret = target(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\src\cli\commands\setup_cicd.py", line 527, in setup_cicd
ensure_apis_enabled(cicd_project, required_apis)
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\src\cli\utils\cicd.py", line 361, in ensure_apis_enabled
result = run_command(
^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\backoff\_sync.py", line 105, in retry
ret = target(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\pipx\venvs\agent-starter-pack\Lib\site-packages\src\cli\utils\cicd.py", line 459, in run_command
result = subprocess.run(
^^^^^^^^^^^^^^^
File "C:\Users\aldo\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 548, in run
with Popen(*popenargs, **kwargs) as process:
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\aldo\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\aldo\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified
Sorry from this error is a bit difficult to debug. Perhaps you don't have gcloud CLI installed?
What if you try running gcloud services list --project=agent-project-one --filter=config.name:secretmanager.googleapis.com --format=json from terminal?
Thanks for the reply.
The command runs ok and returns []
I've tried to uninstall and reinstall cloud sdk and also python 3.12.9 and the error persists.
I've noticed that when I run the agent-starter-pack create my-awesome-agent I get the Unknown account and later when verifing Vertex AI is enabled it fails with WinError 2 again
You are logged in with account: 'Unknown account'
> You are using project: 'agent-project-one'
> Do you want to continue? (The CLI will check if Vertex AI is enabled in this project) [Y/skip/edit] (Y): Y
> Warning: GCP environment setup failed: [WinError 2] The system cannot find the file specified
> Please check your authentication settings and permissions. Visit
https://cloud.google.com/vertex-ai/docs/authentication for help.
> Continuing with template processing...
regarding the Unknown account, I looked at the source code and I noticed it is supposed to do gcloud config get-value account which doesn't get my account.
but in command line it returns the correct commanline.
So it seems some issue, running the gcloud commands, can be a python version issue?
Maybe have a look at your authentication in the terminal.
Try running gcloud auth login --update-adc to do that.
Having the same issue. Got the "unknown account" issue solved but the win error 2 remains. Did you solve it?
@benj01 what's "win error 2"?
I got this (even after re-initialization of Google Cloud CLI):
=== GCP Agent Starter Pack 🚀=== Welcome to the Agent Starter Pack! This tool will help you create an end-to-end production-ready AI agent in Google Cloud!
Debug mode enabled DEBUG:root:Starting CLI in debug mode
Please select a agent to get started:
- adk_base - A base ReAct agent built with Google's Agent Development Kit (ADK)
- agentic_rag - ADK RAG agent for document retrieval and Q&A. Includes a data pipeline for ingesting and indexing
documents into Vertex AI Search or Vector Search. - langgraph_base_react - An agent implementing a base ReAct agent using LangGraph
- crewai_coding_crew - A multi-agent system implemented with CrewAI created to support coding activities
- live_api - A real-time multimodal RAG agent powered by Gemini Live API, supporting audio/video/text chat with
vector DB-backed responses
Enter the number of your template choice (1): 1 DEBUG:root:Selected agent: None
Please select a deployment target:
- Vertex AI Agent Engine - Vertex AI Managed platform for scalable agent deployments
- Cloud Run - GCP Serverless container execution
Enter the number of your deployment target choice (1): 1 DEBUG:root:Selected deployment target: agent_engine
Enter desired GCP region (Gemini uses global endpoint by default) (us-central1): DEBUG:root:Selected region: us-central1 DEBUG:root:Setting up GCP... DEBUG:root:Verifying GCP credentials... DEBUG:google.auth._default:Checking D:\xxxx.json for explicit credentials as part of auth process...
You are logged in with account: 'xxxx.iam.gserviceaccount.com' You are using project: xxxx' Do you want to continue? (The CLI will check if Vertex AI is enabled in this project) [Y/skip/edit] (Y): WARNING:root:GCP environment setup failed: [WinError 2] Das System kann die angegebene Datei nicht finden Warning: GCP environment setup failed: [WinError 2] Das System kann die angegebene Datei nicht finden Please check your authentication settings and permissions. Visit https://cloud.google.com/vertex-ai/docs/authentication for help. Continuing with template processing...
the .json file is in place, i get a different error when i rename or delete it. Any help is appreciated!
By ChatGPT:
Title: Solution for [WinError 2] and 403 Permission Denied on Windows using agent-starter-pack
Summary
When running agent-starter-pack create on Windows within a Python virtual environment, the process would fail at the GCP setup stage with [WinError 2] The system cannot find the specified file. This occurred even when gcloud, terraform, and other dependencies were correctly installed and accessible in the system's PATH.
After fixing the initial file-not-found error, a second error appeared: 403 Permission 'aiplatform.endpoints.predict' denied, which blocked the Vertex AI connection test.
This document outlines the root causes and provides the step-by-step solution to resolve both issues.
Environment
- Operating System: Windows
- Shell: PowerShell
-
Python: Running in a virtual environment (
.venv) -
Key Tools:
- Google Cloud SDK (
gcloudCLI) -
agent-starter-pack -
terraform
- Google Cloud SDK (
Root Cause Analysis
The problem consisted of two independent issues in sequence:
-
[WinError 2]- Python Subprocess Pathing on Windows: The core of theWinError 2was how the Pythonsubprocess.run()function interacts with the Windows environment. When called from within the Python script (withoutshell=True), it would not automatically resolve the path to executables likegcloud.cmdin the same way an interactive PowerShell session does. The script was looking for a file literally namedgcloud, notgcloud.cmd, and the OS couldn't find it. This issue was present in multiple files within theagent-starter-packsource code, causing the error to reappear after the first fix. -
403 Permission Denied- Insufficient IAM Permissions: After resolving the pathing issues, the script could successfully executegcloudcommands and communicate with the Google Cloud project. The new error occurred because the Service Account being used (GOOGLE_APPLICATION_CREDENTIALS) did not have the necessary IAM permissions to perform the pre-flight check, which involves making a test API call to a Vertex AI model. Specifically, it lacked theaiplatform.endpoints.predictpermission.
Step-by-Step Solution
Part 1: Fixing the [WinError 2] File Not Found Error
The solution is to edit the agent-starter-pack source files within your virtual environment to programmatically find the absolute path to the gcloud executable before trying to run it.
1. Locate and Edit gcp.py:
-
File:
<path-to-your-project>\.venv\Lib\site-packages\src\cli\utils\gcp.py -
Action: Add
import shutilat the top of the file. Then, in theverify_credentialsfunction, modify thesubprocess.runcall to useshutil.which().-
Before:
result = subprocess.run( ["gcloud", "config", "get-value", "account"], # ... args ) -
After:
gcloud_path = shutil.which("gcloud") if not gcloud_path: raise FileNotFoundError("gcloud executable not found in PATH.") result = subprocess.run( [gcloud_path, "config", "get-value", "account"], # ... args )
-
Before:
2. Locate and Edit create.py:
-
File:
<path-to-your-project>\.venv\Lib\site-packages\src\cli\commands\create.py -
Action: This file contains several functions that call
gcloud. Apply the sameshutil.which("gcloud")fix to everysubprocess.runcall that usesgcloud. The main functions to check areset_gcp_projectand_handle_credential_verification.-
Example Change in
set_gcp_project:# Add 'import shutil' at the top of the file # In the function: gcloud_path = shutil.which("gcloud") if not gcloud_path: raise FileNotFoundError("gcloud executable not found in PATH.") subprocess.run( [gcloud_path, "config", "set", "project", project_id], # ... args )
-
Example Change in
3. (Optional but Recommended) Clear Python Cache:
- After saving the edits, delete the
__pycache__directories in the folders where you edited files. This forces Python to recompile the source code and ensures your changes are applied.-
...\Lib\site-packages\src\cli\utils\__pycache__ -
...\Lib\site-packages\src\cli\commands\__pycache__
-
Part 2: Fixing the 403 Permission Denied Error
The solution is to grant the Vertex AI User role to the service account that the gcloud CLI is using.
1. Grant IAM Role via Command Line:
-
Run the following
gcloudcommand in your terminal, replacing the placeholders with your project ID and service account email.gcloud projects add-iam-policy-binding <your-project-id> --member="serviceAccount:<your-service-account-email>" --role="roles/aiplatform.user"Example:
gcloud projects add-iam-policy-binding cognica-462620 --member="serviceAccount:[email protected]" --role="roles/aiplatform.user"
2. Wait for Permissions to Propagate:
- It can take up to 60 seconds for IAM changes to take effect across Google Cloud.
Conclusion
After applying the code patches to handle Windows pathing and granting the correct IAM role, the agent-starter-pack create command should execute successfully, allowing you to create and deploy your Vertex AI Agent.
Same problem, was trying to do the hackathon son gonna be a waste of a weekend if I'm not gonna be able to simply deploy. I don't get why there isn't just a simple git deploy method before all this heavy weight stuff.
Enter desired GCP region (Gemini uses global endpoint by default) (us-central1):
> You are logged in with account: 'Unknown account'
> You are using project: 'vertexai-463203'
> Do you want to continue? (The CLI will check if Vertex AI is enabled in this project) [Y/skip/edit] (Y): Y
> Warning: GCP environment setup failed: [WinError 2] The system cannot find the file specified
> Please check your authentication settings and permissions. Visit
https://cloud.google.com/vertex-ai/docs/authentication for help.
> Continuing with template processing...
Tried
gcloud auth login
gcloud config set project vertexai-463203 shows expected results for my account email and project
gcloud config list
gcloud auth list shows expected results for my account email and project
gcloud auth application-default login
commands try in cmd and in python .venv active command prompt in case that matters
OH lolol even worse project is windows hostile but not in the requirements in the readme. horrible DX to just be able to deploy a python script.
🚀 To get started, run the following command:
cd assemble && make install && make playground
(.venv) C:\Projects\agents-assemble>cd assemble && make install && make playground
'make' is not recognized as an internal or external command,
operable program or batch file.
Hi everyone, addressed 2 key windows compatibility issues in https://github.com/GoogleCloudPlatform/agent-starter-pack/pull/278 !
wrt the issue regarding authorization
> Warning: GCP environment setup failed: [WinError 2] The system cannot find the file specified
please note that this is only an extra check to validate that your gcp environment is configured.
If the "automated" credential setup fails you can still continue - of course authenticating later with using gcloud. e.g gcloud auth login --update-adc
Let me know if that works!
For me, I changed run_command or subprocess.run to include shell=True or change command gcloud to gcloud.cmd can find the path correctly.