I am running a service on Google Flexible App engine with Flask and python 3.6. As I have to use pandas and numpy and many other such extensions, I can't use GAE standard.
My app.yaml starts like this
service: my_service
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
python_version: 3
my main python file stopped working (i.e deploying), when i tried to add matplotlib to make a png and store seperately on my bucket. I dont need to display anything but just store the file
I have an import line
import matplotlib.pyplot as plt
the stacktrace from Google cloud shows the following
import matplotlib.pyplot as plt
File "/env/lib/python3.6/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/env/lib/python3.6/site-packages/matplotlib/backends/__init__.py", line 62, in pylab_setup
[backend_name], 0)
File "/env/lib/python3.6/site-packages/matplotlib/backends/backend_tkagg.py", line 4, in <module>
from . import tkagg # Paint image to Tk photo blitter extension.
File "/env/lib/python3.6/site-packages/matplotlib/backends/tkagg.py", line 5, in <module>
from six.moves import tkinter as Tk
File "/env/lib/python3.6/site-packages/six.py", line 92, in __get__
result = self._resolve()
File "/env/lib/python3.6/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/env/lib/python3.6/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/opt/python3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libBLT.2.5.so.8.6: cannot open shared object file: No such file or directory
The last line seems telling, here https://wiki.python.org/moin/TkInter it says
If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do not edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
But how can I configure python3 on the google flexible app engine? Is there some additional file I can install in my 'requirements.txt'? That's the text file which contains the names of all the external dependencies like pandas, numpy, scipy etc that can be pip-installed
EDIT: I found this Generating a PNG with matplotlib when DISPLAY is undefined
basically
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
However, I still can't find where GAE flex is saving the file so created by fig.savefig so I can move it to a bucket or something.