我正在尝试在我的 Windows 机器上安装 Google Cloud SDK。我目前在这台机器上安装了 Python 2.7,它位于这样的系统变量路径中 -> C:\Python27\;
我在安装过程中遇到这个错误:
ERROR: gcloud failed to load: DLL load failed: %1 is not a valid Win32 application.
错误消息还提示我检查 Python 可执行文件:
If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 executable.
因此,我尝试在 install.sh shell 脚本中设置 CLOUDSDK_PYTHON 环境变量...但没有任何效果。这是该文件中的代码:
echo Welcome to the Google Cloud SDK!
if [ -z "$CLOUDSDK_PYTHON" ]; then
if [ -z "$(which python)" ]; then
echo
echo "To use the Google Cloud SDK, you must have Python installed and on your PATH."
echo "As an alternative, you may also set the CLOUDSDK_PYTHON environment variable"
echo "to the location of your Python executable."
exit 1
fi
CLOUDSDK_PYTHON="python"
fi
我已经尝试过 python2.7
,以及可执行文件的路径,C:\Python27
,但是我遇到了这个错误当我尝试使用这些变量运行脚本时:
install.sh: line 128: $'python\r': command not found
我找到了这个 stack question ,但没有一个解决方案对我有用。任何帮助将不胜感激。
最佳答案
当 sdk 指向 virtualenv python 时,我遇到了同样的问题。我通过在 Ubuntu
中使用默认的 python2.7 解决了它在终端输入这个
export CLOUDSDK_PYTHON=/usr/bin/python
关于Google Cloud 安装上的 Python 错误。如何正确设置环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40728513/