You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Windows 11安装Google Cloud CLI失败:'ython'未被识别

Windows 11安装Google Cloud CLI失败:'ython'未被识别

看起来你碰到了一个挺诡异的拼写错误问题——报错里的'ython'' is not recognized明显少了开头的p,大概率是安装脚本在处理Python路径时出现了字符截断,或者环境变量配置有细节疏漏。结合你已经做的操作(添加PATH、设置CLOUDSDK_PYTHON),给你几个排查和解决的方向:

一、先检查CLOUDSDK_PYTHON环境变量的配置细节

你已经设置了这个系统变量,但可能存在以下小问题:

  • 变量值有没有不小心输错字符?比如是不是写成了ython.exe,或者路径里多了多余的引号/空格?
  • 如果你的Python路径包含空格(比如C:\Program Files\Python312\python.exe),变量值需要用双引号包裹;如果路径没有空格,直接写绝对路径即可,比如C:\Python312\python.exe
  • 设置完变量后,一定要重启所有打开的命令提示符/终端,确保新的环境变量生效。

二、手动指定Python路径重新初始化gcloud

安装完成后出现的错误,可能是初始化脚本没正确读取到Python路径,你可以手动指定路径重试:

  1. 打开管理员权限的命令提示符(CMD)
  2. 切换到Cloud SDK的安装目录:
    cd "C:\Program Files (x86)\Google\Cloud SDK"
    
  3. 运行初始化命令并指定Python路径:
    gcloud init --python=C:\Python312\python.exe
    
    (把路径替换成你实际的Python.exe所在路径)

三、排查PATH环境变量的正确性

虽然你说已经验证过python命令可以运行,但还是建议检查:

  • PATH里的Python路径是不是完整的,有没有误写成类似C:\Python312\ython.exe这种错误路径?
  • 确保Python的路径在PATH的靠前位置,避免被其他可能的错误路径覆盖。

四、尝试重新安装最新版Google Cloud CLI

有可能是下载的安装包本身存在脚本瑕疵,你可以:

  1. 先卸载已安装的Cloud SDK(通过控制面板的程序卸载)
  2. 下载最新版本的Google Cloud CLI安装包,选择自定义安装选项,手动指定你的Python3.12.1路径,避免安装程序自动检测出错。

附:你提供的错误日志详情

Output folder: C:\Program Files (x86)\Google\Cloud SDK

Downloading Google Cloud CLI core.

Extracting Google Cloud CLI core.

Create Google Cloud CLI bat file: C:\Program Files (x86)\Google\Cloud SDK\cloud_env.bat

Installing components.

Welcome to the Google Cloud CLI!

Beginning update. This process may take several minutes.

Your current Google Cloud CLI version is: 415.0.0

Installing components from version: 458.0.0

+---------------------------------------------------------+

|            These components will be updated.            |

+---------------------------------+------------+----------+

|               Name              |  Version   |   Size   |

+---------------------------------+------------+----------+

| Bundled Python 3.11             |     3.11.6 | 21.5 MiB |

| Google Cloud CLI Core Libraries | 2023.12.15 | 22.2 MiB |

| gcloud cli dependencies         | 2023.12.08 | 11.8 MiB |

+---------------------------------+------------+----------+

+-----------------------------------------------------------------------------+

|                     These components will be installed.                     |

+-----------------------------------------------------+------------+----------+

|                         Name                        |  Version   |   Size   |

+-----------------------------------------------------+------------+----------+

| BigQuery Command Line Tool                          |    2.0.101 |  1.6 MiB |

| BigQuery Command Line Tool (Platform Specific)      |    2.0.101 |  < 1 MiB |

| Cloud Storage Command Line Tool                     |       5.27 | 11.3 MiB |

| Cloud Storage Command Line Tool (Platform Specific) |       5.27 |  < 1 MiB |

| Cloud Tools for PowerShell                          |   1.0.1.10 | 17.9 MiB |

| Google Cloud CLI Core Libraries (Platform Specific) | 2023.12.15 |  < 1 MiB |

| Google Cloud CRC32C Hash Tool                       |      1.0.0 |  1.3 MiB |

| Windows command line ssh tools                      |            |  3.3 MiB |

| anthoscli                                           |     0.2.46 | 69.5 MiB |

| gcloud cli dependencies                             | 2021.04.16 |  < 1 MiB |

+-----------------------------------------------------+------------+----------+

A lot has changed since your last upgrade.  For the latest full release notes,

please visit:

https://cloud.google.com/sdk/release_notes

#============================================================#

#= Creating update staging area                             =#

#============================================================#

#= Uninstalling: Bundled Python 3.9                         =#

#============================================================#

#= Uninstalling: Google Cloud CLI Core Libraries            =#

#============================================================#

#= Uninstalling: gcloud cli dependencies                    =#

#============================================================#

#= Installing: BigQuery Command Line Tool                   =#

#============================================================#

#= Installing: BigQuery Command Line Tool (Platform Spec... =#

#============================================================#

#= Installing: Bundled Python 3.11                          =#

#============================================================#

#= Installing: Cloud Storage Command Line Tool              =#

#============================================================#

#= Installing: Cloud Storage Command Line Tool (Platform... =#

#============================================================#

#= Installing: Cloud Tools for PowerShell                   =#

#============================================================#

#= Installing: Cloud Tools for PowerShell                   =#

#============================================================#

#= Installing: Default set of gcloud commands               =#

#============================================================#

#= Installing: Google Cloud CLI Core Libraries              =#

#============================================================#

#= Installing: Google Cloud CLI Core Libraries (Platform... =#

#============================================================#

#= Installing: Google Cloud CRC32C Hash Tool                =#

#============================================================#

#= Installing: Google Cloud CRC32C Hash Tool                =#

#============================================================#

#= Installing: Windows command line ssh tools               =#

#============================================================#

#= Installing: Windows command line ssh tools               =#

#============================================================#

#= Installing: anthoscli                                    =#

#============================================================#

#= Installing: anthoscli                                    =#

#============================================================#

#= Installing: gcloud cli dependencies                      =#

#============================================================#

#= Installing: gcloud cli dependencies                      =#

#============================================================#

#= Creating backup and activating new installation          =#

#============================================================#

Performing post processing steps...

............................................................................................................................................................................................................................................................................done.

Update done!

This will install all the core command line tools necessary for working with

the Google Cloud Platform.

For more information on how to get started, please visit:

https://cloud.google.com/sdk/docs/quickstarts

'ython'' is not recognized as an internal or external command,

operable program or batch file.

'

Failed to install.

备注:内容来源于stack exchange,提问作者JabbaThePadd

火山引擎 最新活动