Not able to run dev_appserver with Python 3 only environment

857 views
Skip to first unread message

Ritesh Nadhani

unread,
Aug 12, 2020, 6:37:14 AM8/12/20
to Google App Engine
Hello

I am getting back to GAE after many years. Things have definitely changed. As a new project, I got started with Python 37 runtime. My virtualenv is created using: python3 -m venv ENV and thus does not have python2.

When I try to run my app in local mode using dev_appserver.py (i am just trying to play around with the sample app from the documentation), I get:

dev_appserver.py app.yaml
ERROR: (dev_appserver) python2: command not found

I installed google-cloud-sdk using brew with: brew cask install google-cloud-sdk.

As of now, my only requirement for my app is GAE and datastore and I am hoping to be able to use the datastore emulator with the above.

Ritesh

Alexis (Google Cloud Platform Support)

unread,
Aug 13, 2020, 3:33:42 PM8/13/20
to Google App Engine
Hello Ritesh,

I looked in our internal issues and I did not find this error posted. It could be a new one. However, a quick Google search shows that someone here[1] downgraded to an older version of the SDK and it worked. Older versions of the SDK can be found here[2].

If it does work with an older version, it could mean that there is an issue. And we would need to report that in the issue tracker here[3], under "Cloud SDK issues". However, there are many other possibilities (too many not visible) and it would be good to isolate further without brew, etc.. Just for testing under which environment/config this happens.

If you could, please let us know if it works with an older version of Cloud SDK and under which specific environment. Otherwise, this may need to be a support ticket. Thank you in advance.

wesley chun

unread,
Sep 17, 2020, 4:52:56 AM9/17/20
to google-a...@googlegroups.com
Hi Ritesh, let me offer some alternatives in addition to Alexis' recommendations:
  1. I would avoid using Homebrew for installing the Cloud SDK... we have a note at the bottom of the first section of the App Engine install docs that says, "Avoid using a package manager such as apt or yum to install the Cloud SDK." Homebrew is a package manager.
  2. Here are the Cloud SDK recommended installation instructions
  3. When you called  `dev_appserver.py` above, it looks like it was looking for Python 2 which it couldn't find. I'm wondering whether this is because: 1) you have an older version of dev_appserver.py that was based on python2, or 2) you didn't activate your virtualenv and somehow you were calling Apple's Python 2 binary. Anyway, if you reinstall the SDK, you shouldn't see this issue again.
  4. The Cloud SDK should be installed in your home directory where dev_appserver.py should be available in its bin directory, i.e., ~/google-cloud-sdk/bin/dev_appserver.py
  5. OTOH (on the other hand), since you're no longer using `webapp2` and likely using Flask, you should be able to start the development server that comes with Flask: `python main.py` should work, esp. if you're using the QuickStart sample, making it so you don't have to use dev_appserver.py any more.
  6. If you're going to use Datastore w/the App Engine NDB library (Py2) back in the day, to run on Py3, you would do a minor migration to the *Cloud* NDB library to keep the same interface to Datastore you're familiar with.
  7. If instead, you want to use the newer interface to Datastore, you'd use the Cloud Datastore client library instead of Cloud NDB.
  8. To make things slightly *more* complex, you should know the next generation of Datastore has been released, and it had a slight product rebrand as Cloud Firestore to indicate it has inherited some key features of the Firebase realtime database, however storing & querying data w/Firestore is quite different from Datastore, so for the time being & backwards-compatibility for Datastore users, developers can choose to run Cloud Firestore in Datastore mode (and use the Datastore client library)
  9. If instead you'd prefer to start from scratch with the latest hotness, then you can use Cloud Firestore in native mode. Here are comparisons b/w Firestore in native vs Datastore modes to help you decide.
  10. The Datastore emulator is now a Java app... read more about it here
Anyway, hope some of this helps!
--Wesley
--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"A computer never does what you want... only what you tell it."
    wesley chun :: @wescpy :: Software Architect & Engineer
    Developer Advocate at Google Cloud by day; at night...
    Python training & consulting : http://CyberwebConsulting.com
    "Core Python" books : http://CorePython.com
    Python blog: http://wescpy.blogspot.com

Will Reiher

unread,
Oct 8, 2020, 1:30:31 PM10/8/20
to Google App Engine
dev_appserver.py requires python 2. You actually run it with python2 and it will spawn a python 3 process to handle your python3 app. This allows it to support app engine services that use different languages.
Reply all
Reply to author
Forward
0 new messages