Description
Google App Engine is a restricted Python environment which now supports matplotlib on the production server (see Third-party Libraries), due to extensive modifications which Google made to the codebase to get it working. However, the development server runs unmodified code for third-party libraries. The current version of Matplotlib (tested with 9690232 as of 14-03-2013) crashes if "import matplotlib
" is run on the dev appserver:
Traceback (most recent call last):
File "/path/to/matplotlib/__init__.py", line 846, in <module>
rcParams = rc_params()
File "/path/to/matplotlib/__init__.py", line 757, in rc_params
fname = matplotlib_fname()
File "/path/to/matplotlib/__init__.py", line 646, in matplotlib_fname
home = get_home()
File "/path/to/matplotlib/__init__.py", line 300, in wrapper
ret = func(*args, **kwargs)
File "/path/to/matplotlib/__init__.py", line 496, in _get_home
raise RuntimeError('please define environment variable $HOME')
RuntimeError: please define environment variable $HOME
This is just one of the issues (fix that one, and more spring up). There are three major blockers:
- Matplotlib expects the user to have a writable $HOME directory, so it will not work in any environment where the user does not have a home directory, or where there is a non-writable file system.
- App Engine does provide a
subprocess
module, but it is empty. Therefore, any attempt to usesubprocess.Popen
on App Engine results inAttributeError
being raised. - The
ps
backend writes to a temporary file, then reads it back in, even when not using an external distiller. This will not work in any environment where there is a non-writable file system.
We (the Google App Engine Python team) have patched these three issues to get Matplotlib working in our production environment. We propose sending these patches upstream so that Matplotlib will work out-of-the-box on App Engine and other restricted environments which ban file writing and use of subprocess.