8000 Cannot import matplotlib on Google App Engine dev appserver · Issue #1823 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Cannot import matplotlib on Google App Engine dev appserver #1823
Closed
@mgiuca-google

Description

@mgiuca-google

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 use subprocess.Popen on App Engine results in AttributeError 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.

Metadata

Metadata

Assignees

No one assigne 369C d

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0