skip to Main Content

I’m trying to upgrade my app engine app from python 2 to python 3. My app uses the app engine datastore (now cloud datastore). Google’s docs are not at all clear about how to test this stuff locally. I’ve tried dev_appserver.py (which I’ve used for years with Python 2) but that’s yielding the following error:

File "/usr/lib/google-cloud-sdk/platform/google_appengine/_python_runtime.py", line 108, in <module>
    assert sys.version_info[0] == 2
AssertionError

I do have both Python 3 & Python 2 installed.

… I’m using Ubuntu for development in a Python virtual environment

Thank you

2

Answers


  1. Chosen as BEST ANSWER

    The short answer is that dev_appserver.py does now work with Python 3. Either invoke it directly with python3 or make sure that python3 is the default python interpreter.


    1. File "/usr/lib/google-cloud-sdk/platform/google_appengine/_python_runtime.py", line 108, in assert sys.version_info[0] == 2 AssertionError

      The above error means you tried to start dev_appserver.py with a non-python2 executable. dev_appserver.py needs to be invoked with Python2 no matter the runtime or version in which your target App is written (i.e. even if your App is written in Python 3). As the documentation says

      If Python 2 is not the default interpreter on your system, you need to run python2 dev_appserver.py to ensure the Python 2 interpreter is used

      Summary: Make sure Python2 is your default Python executable in which case you can simply do dev_appserver.py app.yaml. If Python2 isn’t your default Python executable, then you have to use the command python2 dev_appserver.py

    2. If you use the bundled APIs, then I don’t believe you’ll need the Cloud Datastore Emulator. You can run your App the same way you were doing it for Python 2. To enable bundled APIs for Python 3, see Google documentation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search