QuantEcon / MatchingMarkets.py

Python toolbox for simulation of matching markets in economics
BSD 3-Clause "New" or "Revised" License
107 stars 41 forks source link

ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running #1

Closed starly closed 4 years ago

starly commented 4 years ago

Attempting to import MatchingMarkets in Google Codelab environment running Python 3.6 however getting the following error:

import matchingmarkets as mm

ImportError Traceback (most recent call last)

in () ----> 1 import matchingmarkets as mm 2 #import matplotlib 3 #matplotlib.use('TKAgg') 4 frames /usr/local/lib/python3.6/dist-packages/matplotlib/pyplot.py in switch_backend(newbackend) 234 "Cannot load backend {!r} which requires the {!r} interactive " 235 "framework, as {!r} is currently running".format( --> 236 newbackend, required_framework, current_framework)) 237 238 rcParams['backend'] = rcParamsDefault['backend'] = newbackend ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running --------------------------------------------------------------------------- After doing some research on the error, it seems others have had similar error with matplotlib, though it is not clear if the suggested workaround would help in this case. Any insights would be greatly appreciated.. or alternatively if you happen to have a clean install with MatchingMarkets already working somewhere in an online notebook/environment , please advise where it can be accessed. Thanks.
VHRanger commented 4 years ago

Hey, author of the package here.

I didn't work on this code for a while, I just downloaded it and I'll take a look.

Are all codelab notebook similar to colab notebooks from here: https://colab.research.google.com/ ?

I think the issue is from the interactive plots (like the one at the top of the README) not playing nice with some package versions. I'll update here when I find out.

starly commented 4 years ago

Hi, pardon the typo .. yes, was using a colab environment via the Google link you indicated.

Thank you in advance for taking a look.

VHRanger commented 4 years ago

The error is specific to colab it seems, because it runs on headless servers, the plotting backend can't work.

I added a bandaid fix so the package can still be imported, but you won't be able to plot the interactive visualizations in the colab environment