tom
tom

Reputation: 2299

Running app engine local development server from command prompt (v1.9.36) - Google Cloud complications (No module named portpicker)

I've been running app engine local development server from the command prompt for 3 years without any issues (windows 7, 64bit). I just updated to v1.9.36 (download 960cfe2157c6e984802db4b0224cfe8273d727dc from this page), and now when I run

dev_appserver.py [anything]

I get:

Traceback (most recent call last): File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform/google_appengine\dev_appserver.py", line 82, in _run_file(file, globals()) File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform/google_appengine\dev_appserver.py", line 78, in _run_file execfile(_PATHS.script_file(script_name), globals_) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 37, in from google.appengine.tools.devappserver2 import dispatcher File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\dispatcher.py", line 29, in from google.appengine.tools.devappserver2 import module File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\module.py", line 55, in from google.appengine.tools.devappserver2 import http_runtime File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\http_runtime.py", line 53, in import portpicker ImportError: No module named portpicker

The strange thing is that if I use the SDK GUI, and hit the 'Run' button, it launches just fine, no errors. So my guess is that when running from the command line, it's using the version of 'dev_appserver.py' in the Cloud SDK folder, whereas the GUI is running the version in C:\Program Files (x86)\Google\google_appengine\. But my environment variables are:

GAE_SDK_ROOT: C:\Program Files (x86)\Google\google_appengine

PATH: lots of other things, plus C:\Program Files (x86)\Google\google_appengine\

And I dont see any reference to Cloud SDK, so I cant figure why the version in the folder would be run.

There are versions of dev_appserver.py in both C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine and C:\Program Files (x86)\Google\google_appengine

Seems that in combining GAE SDK with Google Cloud, Google has made this more complicated than it used to be..

[UPDATE]

If I run echo %PATH% then among many other things, I see

C:\Program Files\Google\Cloud SDK\google-cloud-sdk..

before

C:\Program Files (x86)\Google\google_appengine\

Which explains why it's running that version. The question now is: why is the former in my PATH if I havent set it in my user PATH variable? Where else is the Windows PATH manipulated? Presumable the Google Cloud SDK installer did this - how do I undo it?

Upvotes: 1

Views: 762

Answers (3)

Allan Veloso
Allan Veloso

Reputation: 6369

As an alternative to the other answers, if you do not have the old standalone Google App Engine installed and only uses the Google SDK, you can also install portpicker with the following command line (assuming you have pip installed):

pip install portpicker

Upvotes: 1

tom
tom

Reputation: 2299

New answer

I turns out that the Cloud SDK folder was in my system path, which is checked before the user path, so the version of dev_appserver.py in Cloud SDK was being executed, rather than the more up to date version in the app engine folder.

To fix this I simply removed the Cloud SDK from my system path, using the handy app detailed here

Original answer

I worked out that if I rename the Cloud SDK folder in C:\Program Files\Google this fixes it. But that's a hacky fix, and presumably makes the Cloud SDK functionality unavailable (I dont think I currently need it).

So I'd still like a proper answer to this question. It seems that I need a way to control which version of dev_appserver.py gets run, and short of setting my environment variables (which I've already done) I dont know what else to try.

Upvotes: 1

Dan Cornilescu
Dan Cornilescu

Reputation: 39814

Executing dev_appserver.py [anything] will launch the first dev_appserver.py executable encountered in your executable PATH environment, which appears to be not the one you expect :)

You have 2 options:

  • update your PATH as needed
  • execute the desired dev_appserver.py by specifying its full path:
C:\Program Files (x86)\Google\google_appengine\dev_appserver.py [anything]

This answer is somehow related: appcfg.py not working in command line

Upvotes: 1

Related Questions