Python in Google Cloud Functions

Python 3.7 is supported now.
Steps to create one via the google cloud console:

  1. go to google cloud functions in the google cloud console and click on create function enter image description here

2.specify the function's properties enter image description here

  1. select trigger enter image description here

4.change runtime to python 3.7 enter image description here

  1. enter your cloud function logic and entry point enter image description here

  2. enter python dependencies in requirements.txt enter image description here


EDIT: As of July 2018 there is now a Python runtime (3.7) available for Google Cloud Functions!

OLD ANSWER: Google Cloud Functions (GCF) are written in JavaScript (executed in a Node.js runtime), so there is no way for them to actually handle Python at this moment. There is a Python module at GitHub that you might have come across and it can be used to write and deploy GCF with one of three trigger types: http, Pub/Sub and bucket. The module takes care of translating your Python logic to a JavaScript code that is later run inside Google Cloud Platform.

When it comes to other packages like pandas, the ‘translation’ into JavaScript was not prepared for them by anyone AFAIK. If you really don’t like the idea of jumping into JavaScript and writing the Cloud Function code on your own (with the logic you intended to use in a Python script), you have a possible workaround. You can evoke your Python script from inside of the Cloud Function written in JS - the idea was discussed in this topic. Another way is using Object Change Notifications or Pub/Sub Notifications as explained here.


As of 19th July 2018, Google Cloud Functions supports Python 3.7.

Kindly check the Runtime environment to find the Python 3.7 runtime and sample script (based on Flask) .

--UPDATED--

Official Documentation for the Google Cloud Functions - Python 3.7 support Beta Release.

This is a beta release of the Python runtime for Google Cloud Functions. This feature might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.

SkLearn, Numpy is supported in Google Cloud function. Also I've run a sample test to confirm the availability of Pandas as well and its working fine.

https://github.com/mkanchwala/google-functions-python-example

Hope this helps to all the "Py" lovers.


You can use AWS lambda as well if you want to work around and still use Python as your main language. Some modules/packages will need to be imported via zip file with AWS Lambda but it has a broader range of usable languages than GCF