Google Cloud build error “print_env_info.py: error

2019-08-27 19:19发布

问题:

I'm trying to get a Google Cloud development environment up and running on my Windows (64 bit) computer.

I followed instructions for Java at https://console.developers.google.com/start/appengine on my Windows computer but on step 6 ("Create Your Project and Deploy") I got this error message:

D:\google-app-engine\appengine-try-java>appcfg.cmd -A midyear-tempo-554 update t arget\appengine-try-java usage: print_env_info.py [-h] item print_env_info.py: error: unrecognized arguments: Osofsky\AppData\Roaming\gcloud \tmp-env-info-10521.txt

I was able to complete all the other steps. The only anomaly was in Step 4 ("Run Your App Locally") where I got the following error when I tried to run install.bat:

To use the Google Cloud SDK, you must have Python installed and on your PATH. As an alternative, you may also set the CLOUDSDK_PYTHON environment variable to the location of your Python executable.

I successfully solved this problem by adding the following line to install.bat:

set CLOUDSDK_PYTHON=C:\Python27\python.exe

I wasn't sure if this caused "print_env_info.py: error: unrecognized arguments", but it seems related because they both have to do with environment variables. So I added CLOUDSDK_PYTHON=C:\Python27\python.exe to my user-level environment variables. I then started a new command prompt, confirmed via a "set" command that CLOUDSDK_PYTHON=C:\Python27\python.exe had registered, and tried again but I still got this error:

D:\google-app-engine\appengine-try-java>appcfg.cmd -A midyear-tempo-554 update t arget\appengine-try-java usage: print_env_info.py [-h] item print_env_info.py: error: unrecognized arguments: Osofsky\AppData\Roaming\gcloud \tmp-env-info-8445.txt

Any ideas?

回答1:

Problem seems to be the space in the directory name, where it tries to print temporary file. Work around steps that solved this problem for me:

1) Create some new empty directory with no spaces in the path, for example, D:\google-cloud-sdk\tmp

2) Modify D:\google-cloud-sdk\bin\appcfg.cmd file by replacing %APPDATA%\gcloud\ with your newly created directory path D:\google-cloud-sdk\tmp\



回答2:

A representative from Google Enterprise Support named Jordan gave me the revised appcfg.cmd file below. It helped get me past the error I was having. Unfortunately there's another issue now, but I think the solution below addresses the original error I posted about. Thanks Heeryu and Tatiana for your offers of help.

@echo off 

rem Copyright 2013 Google Inc. All Rights Reserved. 



cmd /c "python "%~dp0bootstrapping\prerun.py" --command-name=appcfg-java --component-id=gae-java --check-credentials --check-updates" 

IF %ERRORLEVEL% NEQ 0 ( 

EXIT /B %ERRORLEVEL% 

) 



SETLOCAL 



set TMPFILE=%APPDATA%\gcloud\tmp-env-info-%RANDOM%.txt 



cmd /c "python "%~dp0bootstrapping\print_env_info.py" gae_java_path > "%TMPFILE%" 

IF %ERRORLEVEL% NEQ 0 ( 

EXIT /B %ERRORLEVEL% 

) 



set /p credential_path= < "%TMPFILE%" 

del "%TMPFILE%"



cmd /c ""%~dp0..\platform/appengine-java-sdk\bin\appcfg.cmd" --oauth2 --oauth2_config_file="%credential_path%" %*" 

IF %ERRORLEVEL% NEQ 0 ( 

EXIT /B %ERRORLEVEL% 

) 



ENDLOCAL