0

I'm trying to create a Python 3 application for Google App Engine (using PyCharm).

I think I'm running into a basic problem in which a module named "google" is defined in 2 places: in the Google App Engine directory created by gcloud install, and in my project's venv directory when I pip install add-ons such as google-cloud-ndb via the requirements.txt file.

When I select PyCharm Settings | Frameworks | App Engine and specify the directory into which gcloud installed App Engine, the editor can resolve things like import google.appengine but not import google.cloud. If I unselect the App Engine Framework, then the editor can find import google.cloud, but not import google.appengine.

All the code examples just list import google.xyz, so I imagine when I deploy, Google will resolve all this correctly. But it also means I probably shouldn't play around with naming or imports either.

This is so basic. How is this handled?

Roopa M
  • 2,171
  • 4
  • 12
Dev93
  • 668
  • 1
  • 6
  • 18
  • Can you confirm that you followed [these](https://stackoverflow.com/a/72825830/18265570) while doing `pip install`. and what is the `python` version you are using? Have you tried installing[`google-api-python-client`](https://stackoverflow.com/a/72825830/18265570)? – Roopa M Aug 08 '23 at 06:30
  • I am using Python3.9. The venv is working correctly, and resolves other non-conflicting packages such as Flask. The problem is that PyCharm can only resolve a package in one place, and now 'google' exists in 2 places (local App Engine installation and venv), with different modules. I don't understand why everyone doesn't have this problem? If I manually copy the files into one location the editor can resolve it, but this seems like a bad idea. – Dev93 Aug 08 '23 at 12:32

1 Answers1

0

The solution is to create a Flask project, not an App Engine project, and then copy installed App Engine modules into the project's venv, so PyCharm can see all google sub-modules in one place.

There's more to getting PyCharm to truly develop/run/debug Python 3 App Engine apps, though: see How to test/run/debug Non-Legacy App Engine project using PyCharm on Windows

Dev93
  • 668
  • 1
  • 6
  • 18