Google Cloud Install上的Python错误.如何正确设置环境变量? [英] Python Error on Google Cloud Install. How do I properly set the environment variable?
问题描述
我正在尝试在 Windows 计算机上安装Google Cloud SDK.我当前在此计算机上安装了Python 2.7,它位于系统变量路径中,如下所示-> C:\Python27\;
I am trying to install the Google Cloud SDK on my Windows machine. I have Python 2.7 currently installed on this machine, and it's located in the System Variables Path like this -> C:\Python27\;
安装过程中出现此错误:
I am getting this error during installation:
错误:gcloud加载失败:DLL加载失败:%1不是有效的Win32 应用程序.
ERROR: gcloud failed to load: DLL load failed: %1 is not a valid Win32 application.
该错误消息还提示我检查Python可执行文件,方法是:
The error message also prompts me to check the Python executable by saying:
如果不是,请将环境变量CLOUDSDK_PYTHON设置为 指向有效的Python 2.7可执行文件.
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环境变量...但是没有任何效果.这是该文件中的代码:
So, I'm trying to set the CLOUDSDK_PYTHON environment variable in the install.sh shell script...But nothing is working. Here is the code from that file:
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
,但是当我尝试使用这些变量运行脚本时遇到了此错误:
I have tried python2.7
, and the path to the executable, C:\Python27
, but I'm getting this error when I try to run the script with those variables:
install.sh: line 128: $'python\r': command not found
我发现了这个堆栈问题,但没有一个解决方案对我有用.任何帮助将不胜感激.
I found this stack question, but none of the solutions worked for me. Any help would be great appreciated.
推荐答案
当 sdk 指向 virtualenv python 时,我遇到了同样的问题.我通过使用 Ubuntu
I had the same issue when the sdk was pointing to the virtualenv python. I solved it by using the default python2.7 in Ubuntu
在终端输入
export CLOUDSDK_PYTHON=/usr/bin/python
这篇关于Google Cloud Install上的Python错误.如何正确设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!