I am trying to run the basic helloworld code described here https://cloud.google.com/appengine/docs/python/. However, whenever I try the dev_appserver.py helloworld/ command, I get a usage error for the dev_appserver.py command.
I have installed Python 2.7 and also have Python 2.7 Anaconda installed on my system. Could the Anaconda Python be the cause of the issue?
The file structure of my code is as follows:
I have tried executing the dev_appserver.py helloworld/ command from inside the 'Project' folder and the 'helloworld' folder. But I get the same error in both cases.
Any help would be greatly appreciated!
Thanks!
I think I have found the "real" problem behind this error.
Tried putting some print
statements in the dev_appserver.py
file and found that what ever argument we are giving is not being passed and hence the error. On googling came across this SO post which explains the problem. On doing that change the following command worked flawlessly :D
dev_appserver.py app.yaml
Quoting that SO answer for easier reference:
I think I solved this. For some reason there is a SECOND place in the registry (besides that shown by the file associations stored in HKEY_CLASSES_ROOT\Python.File\shell\open\command):
[HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command] @="\"C:\\Python25\\python.exe\" \"%1\" %*"
This seems to be the controlling setting on my system. The registry setting above adds the "%*" to pass all arguments to python.exe (it was missing in my registry for some reason).
You just need to execute the dev_appserver.py
with path to app.yaml
in the command itself, as suggested in comments.
I think OP could've identified a potential issue when describing multiple Python installations.
If I don't specify which Python installation (I thought I only had one...), then, it fails:
C:\Python27>"C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\dev_appserver.py" "C:\users\jessmine\documents\ttbtamer\app.yaml"
usage: dev_appserver.py [-h] [-A APP_ID] [--host HOST] [--port PORT]
...etc...
dev_appserver.py: error: too few arguments
But if I specify which Python to use by invoking Python first, @ C:\Python27\python.exe
, then it works:
C:\Python27>"C:\Python27\python.exe" "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin\dev_appserver.py" "C:\users\jessmine\documents\ttbtamer\app.yaml"
INFO 2016-11-18 10:09:14,299 devappserver2.py:769] Skipping SDK update check.
Anyway since I don't think I have other Python installations on my computer, then I may be misinterpreting the difference here. But for me, the fix is to explicitly invoke python.exe.
(And to be clear, I know about putting the Python.exe location into %PATH%
, but I expected that if it wasn't there, that the error would've been something like "'dev_appserver.py' is not recognized as an internal or external command", rather than executing and printing a Python error....)
EDIT
After changing the "associate a file type or protocol with a specific program" (example here) for *.py
to explicitly use C:\Python27\python.exe , then I no longer needed to manually invoke C:\Python27\python.exe
in my cmd; i.e. my first example worked correctly :
C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin>dev_appserver.py "C:\users\jessmine\documents\ttbtamer\app.yaml"
INFO 2016-11-18 10:33:50,269 devappserver2.py:769] Skipping SDK update check.
I had the same problem. I even installed everything on a fresh machine and I was getting the same error again.
So I "debugged" dev_appserver.py and I discovered that the argument passed to it (i.e. 'app.yaml' or '.' or '\hello_world') was not passed down to the following code file:
...\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\devappserver2.py
In this file the arguments were checked, producing the infamous error "too few arguments". Out of desperation for the time lost, I made a quick (and for sure ugly) patching.
I commented out at lines 302 and 303 the validation rule:
parser.add_argument(
'config_paths', metavar=arg_name, nargs='+', help=arg_help)
At line 758 I replaced:
options.config_paths, options.app_id)
with a static file name:
{'app.yaml'}, options.app_id)
At least now I am able again to start the server and develop my application. Now that I can work again, I will try to understand better how to correct the problem.
I'm not a Python nor a Google App Engine expert, so I hope someone will propose a better correction and a better explanation of the problem, because I cannot believe that Google can release such bugged code!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With