dev_appserver.py: error: too few arguments
I encountered this error shortly after installing the Google Cloud SDK. It made no sense, I was in the correct directory and entered the same command as usual:
But it didn't work!?
To keep things short, I'll leave out the stuff I tried but didn't work (e.g. editing the path). I came upon this SO answer, initially I ignored it because it had 0 points and the previous answers hadn't helped but it held the key all along!
Just like pathrik, I had gotten to the point of adding print statements to dev_appserver.py to see what was going on. Adding
print("SYS ARG:", sys.argv) to the top of the
main() method demonstrated that (for whatever reason) Windows was not passing along arguments to Python; I expected to see "app.yaml" but it was not printed when I ran
Steps to fix:
Open the registry editor by typing "regedit" in the Windows search bar.
Navigate to the correct entry by pasting
Computer\HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\commandinto the address bar.
Edit, modify (an "Edit String" modal should pop open).
%*to the "Value data:" field. Various stackoverflow users have reported slightly different values for this and I had to experiment a bit to get it right. My complete value field:
"C:\Users\Ben\AppData\Local\Google\Cloud SDK\google-cloud-sdk\platform\bundledpython\python.exe" "%1" %*
Yours will be different if you don't use Cloud SDK's bundled Python.