3

Using PyCharm Pro 2019.1.1 on MacOS, writing my app in Python 3 w/Flask, Jinja2, etc. A version of my app is already deployed using App Engine Flexible, and I want the next version to use Datastore for my production environment variables. Having problems trying to follow this post, which requires the following import:

from google.appengine.ext import ndb

For the life of me, I cannot seem to get this import working. I'm sure it will work once my app is deployed (famous last words?), but I'd love to get it working locally too.

Initially tried pip install google-appengine and pip install appengine-sdk, only to discover neither could be installed on my venv.

Google Cloud SDK v241.0.0 is installed at /Users/<me>/google-cloud-sdk, and gcloud commands work in the terminal. gcloud components list shows the app-engine-python component is installed, which is probably irrelevant since I'm using a venv in PyCharm.

PyCharm's documentation instructed me to select the App Engine SDK directory under Languages & Frameworks > Google App Engine.

Selecting /Users/<me>/google-cloud-sdk yields this error:

Traceback (most recent call last):
  File "/Users/<me>/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/PyCharm.app/Contents/helpers/pydev/pydevconsole.py", line 5, in <module>
    from _pydev_comm.rpc import make_rpc_client, start_rpc_server, start_rpc_server_and_make_client
  File "/Users/<me>/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/PyCharm.app/Contents/helpers/pydev/_pydev_comm/rpc.py", line 4, in <module>
    from _pydev_comm.server import TSingleThreadedServer
  File "/Users/<me>/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/PyCharm.app/Contents/helpers/pydev/_pydev_comm/server.py", line 4, in <module>
    from _shaded_thriftpy.server import TServer
  File "/Users/<me>/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/PyCharm.app/Contents/helpers/third_party/thriftpy/_shaded_thriftpy/server.py", line 5, in <module>
    import logging
  File "/Users/<me>/google-cloud-sdk/lib/surface/logging/__init__.py", line 22, in <module>
    from googlecloudsdk.calliope import base
ModuleNotFoundError: No module named 'googlecloudsdk'

Selecting /Users/<me>/google-cloud-sdk/platform/google_appengine seems to get me a bit further, but still yields an error:

Traceback (most recent call last):
  File "/Users/<me>/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/PyCharm.app/Contents/helpers/pydev/pydevconsole.py", line 5, in <module>
    from _pydev_comm.rpc import make_rpc_client, start_rpc_server, start_rpc_server_and_make_client
  File "/Users/<me>/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/191.6605.12/PyCharm.app/Contents/helpers/pydev/_pydev_comm/rpc.py", line 1, in <module>
    import socket
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 53, in <module>
    from enum import IntEnum, IntFlag
ImportError: cannot import name 'IntFlag' from 'enum' (/Users/<me>/google-cloud-sdk/platform/google_appengine/lib/grpcio-1.9.1/enum/__init__.py)

As the console notes, there is no IntFlag object in 'enum'. These errors are immediately shown when I launch Python Console; I don't even get a cursor. Where am I going wrong?

brystmar
  • 185
  • 1
  • 14

1 Answers1

1

The post you referenced applies to the 1st generation standard environment - Python 2.7 - that's the only environment in which the ndb library is supported:

For the other environments you need to use the generic datastore client library. References:

Potentially of interest: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97