Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib web assembly backend causes failures in webworker #11

Open
SimonBiggs opened this issue May 25, 2019 · 3 comments
Open

Matplotlib web assembly backend causes failures in webworker #11

SimonBiggs opened this issue May 25, 2019 · 3 comments

Comments

@SimonBiggs
Copy link

Matplotlib tries to run from js import document. This causes an exception when Pyodide is being run from within a webworker.

@mdboom
Copy link
Contributor

mdboom commented Jun 4, 2019

The wasm backend wouldn't work in a webworker because it requires the DOM. However, running data-only backends in matplotlib seems useful and desirable.

Is this also true if you do

import matplotlib
matplotlib.use('Agg')

?

@SimonBiggs
Copy link
Author

Unfortunately I couldn't actually test that as when I tried to change the backend I ran into pyodide/pyodide#441

That issue certainly was not matplotlib specific. I initially bumped into it running my own code, but I chose matplotlib just as an example that removes as much extra complications out of it...

@worrel
Copy link

worrel commented May 4, 2020

I also recently encountered this problem and matplotlib.use() (as suggested in https://github.com/iodide-project/pyodide/issues/442#issuecomment-498784449) doesn't work because the backend has to be set before the matplotlib import.

The following approach -overriding the MPLBACKEND env var right up front- appears to work:

import os
os.environ['MPLBACKEND'] = 'AGG'

# keep calm & carry on as usual e.g.:
import matplotlib as mpl

@rth rth transferred this issue from pyodide/pyodide Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants