简体   繁体   English

谷歌云 SDk:找不到 Python

[英]Google Cloud SDk: Python was not found

After I install Google cloud sdk in my computer, I open the terminal and type "gcloud --version" but it says "python was not found"在我的电脑上安装谷歌云 sdk 后,我打开终端并输入“gcloud --version”,但它显示“找不到 python”

note: I unchecked the box saying "Install python bundle" when I install Google cloud sdk because I already have python 3.10.2 installed.注意:我在安装 Google Cloud sdk 时取消选中“安装 python 捆绑包”框,因为我已经安装了 python 3.10.2。

so, how do fix this?那么,如何解决这个问题?

Thanks in advance.提前致谢。

As mentioned in the document :文档中所述:

Cloud SDK requires Python;云端SDK需要Python; supported versions are Python 3 (preferred, 3.5 to 3.8) and Python 2 (2.7.9 or later).支持的版本是 Python 3(首选,3.5 到 3.8)和 Python 2(2.7.9 或更高版本)。 By default, the Windows version of Cloud SDK comes bundled with Python 3 and Python 2. To use Cloud SDK, your operating system must be able to run a supported version of Python.默认情况下,Cloud SDK 的 Windows 版本与 Python 3 和 Python 2 捆绑在一起。要使用 Cloud SDK,您的操作系统必须能够运行受支持的 Python 版本。

As suggested by @John Hanley the CLI cannot find Python which is already installed.正如@John Hanley 所建议的,CLI 找不到已安装的 Python。 Try reinstalling the CLI selecting install Python bundle .尝试重新安装 CLI 选择install Python bundle If you are still facing the issue another workaround can be to try with Python version 2.xx如果问题仍然存在,另一种解决方法是尝试使用 Python 版本 2.xx

You can follow the below steps:您可以按照以下步骤操作:

1.Uninstall all Python version 3 and above. 1.卸载所有Python版本3及以上。

2.Install Python version -2.xx (I have installed - 2.7.17) 2.安装Python版本-2.xx(我已经安装了-2.7.17)

3.Create environment variable - CLOUDSDK_PYTHON and provide value as C:\Python27\python.exe 3.创建环境变量-CLOUDSDK_PYTHON并提供值为C:\Python27\python.exe

4.Run GoogleCloudSDKInstaller.exe again. 4.再次运行GoogleCloudSDKInstaller.exe。

On ubuntu Linux, you can define this variable in the .bashrc file:在 ubuntu Linux 上,你可以在.bashrc文件中定义这个变量:

export CLOUDSDK_PYTHON=/usr/bin/python3

On Windows, setting the CLOUDSDK_PYTHON environment variable fixes this, but when I first tried this I pointed the variable to the folder containing the python executable and that didn't work.在 Windows 上,设置 CLOUDSDK_PYTHON 环境变量修复了这个问题,但是当我第一次尝试这个时,我将变量指向包含 python 可执行文件的文件夹,但没有用。 The variable apparently must point to the executable file.该变量显然必须指向可执行文件。 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM