1

I am new to Google Cloud Platform and in my whole I have been working on Python 3. I am trying to find out which version of Python is more complete for Google App Engine: Python 2.7 or Python 3.

As I'm starting to work with Google App Engine I have realised that continuing using Python 3 seems too painful as basic tools like dev_appserver.py are written for Python 2 only. Now I am hitting the opposite problem: cloudstorage module seems to exist only for python3. Again, when I install it, seems the only way I can test read/write to google bucket locally is by authenticating with google.appengine.ext, which in turn only works within dev_appserver.py or remotely. This leaves me confused which environment to chose.

What is a general agreement / what is the focus of Google App Engine: Python 2 or Python 3?

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
Dima Lituiev
  • 12,544
  • 10
  • 41
  • 58

4 Answers4

2

In App Engine, you have to options: the Standard environment and the Flexible environment.

Python 2.7 is available in both Standard and Flexible, while Python 3.6 is only available in Flexible.

Also, the choice between Standard and Flexible depends on what you want to do/what libraries you need:

  • There are some third-party libraries already built-in in the Standard Environment, and you can include other libraries, but, those libraries can't include C extensions, they must be written in pure Python. If you need libraries with C extensions, you will have to move to Flexible.
  • In Standard, you can use propietary libraries (like google.appengine.ext, as you mentioned) to do tasks like accessing databases, while in Flexible you can use other libraries (like the client you mentioned).

There are also another important differences, like pricing, scaling, etc. The choice will depend, as I said, in your needs for your application.

EDIT

dev_appserver.py is only used when developing in Standard. There is a tutorial in here, with Flask. If you are in Flexible, you can test the app locally as if you were running as usual a python file, like in this other example.

You can use buckets in both Standard and Flexible

Mangu
  • 3,160
  • 2
  • 25
  • 42
  • Well, as said I need to be able to test the app locally with something like `dev_appserver.py` and be able to use bucket storage. Both seem to be in the scope of standard, google-specific applications. One works only on 2 and the other on 3. Am I missing something? – Dima Lituiev May 16 '18 at 16:19
2

The python3-only cloudstorage support assumption based on the SO post you referenced is not correct:

GCS is definitely supported in the standard env GAE (i.e. on python 2), you just need to follow the steps from the official documentation: Setting Up Google Cloud Storage and Reading and Writing to Google Cloud Storage.

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

Both were good. But the question is what kind of environment do you want? Standard environment or Flexible environment.

Find your answer in this document: https://cloud.google.com/appengine/docs/python/

0

It kind of depends on what you're using it for. If you're doing data science, for example, I'm seeing a few notices of Python libraries that are (finally) dropping support for Python 2. numpy is one that is dropping support.

Generally speaking, I would recommend Python 3 over Python 2. Why spend time developing in an aging version when its replacement has matured nicely and is more consistent?

ingernet
  • 1,342
  • 2
  • 12
  • 29
  • I know, but this is a general advise not pertaining to Google App Engine. – Dima Lituiev May 16 '18 at 17:49
  • I realize that, and if you’re using this App Engine for data science, package support is something to keep in mind when selecting your language version. Another thing to keep in mind is that GCP is constantly evolving and growing - they are way better than they were a year ago - and it is reasonable to expect that at some point, Python 3 will be their standard moving forward. – ingernet May 16 '18 at 17:52