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

plotsr error #39

Closed
liu3zhenlab opened this issue Jul 1, 2020 · 14 comments
Closed

plotsr error #39

liu3zhenlab opened this issue Jul 1, 2020 · 14 comments
Assignees

Comments

@liu3zhenlab
Copy link

liu3zhenlab commented Jul 1, 2020

I was able to run syri successfully but plotsr returned an error. It would be nice to see how you visualize the result. Please help if you know the potential problem. Thanks.

Here is the code

plotsr -s 1000 -o pdf syri.out $ref $qry

Here is the error:

syri/lib/python3.5/site-packages/matplotlib/font_manager.py:229: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
'Matplotlib is building the font cache using fc-list. '
Traceback (most recent call last):
File "syri/bin/plotsr", line 154, in
plt.switch_backend('Qt5Agg')
File "syri/lib/python3.5/site-packages/matplotlib/pyplot.py", line 221, in switch_backend
newbackend, required_framework, current_framework))
ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running

@mnshgl0110
Copy link
Member

Hi Sanzhen,

Are you trying to run this through a terminal or from something like Jupyter? There is some discussion about this error arising when trying to plot in Jupyter/Google Colab python environment. QuantEcon/MatchingMarkets.py#1

So, I am wondering is the same thing happening here, or it is happening when you run this script directly from bash.

@mnshgl0110 mnshgl0110 self-assigned this Jul 1, 2020
@liu3zhenlab
Copy link
Author

liu3zhenlab commented Jul 1, 2020

plotsr was run in terminals using bash commands. I have tested it in both CentOS and Ubuntu systems. Let me know if more information is needed.

@mnshgl0110
Copy link
Member

Thanks for the information.

Could you please try to edit the plotsr script and change the line:

from matplotlib import pyplot as plt

to

import matplotlib
matplotlib.use('Qt5Agg')
from matplotlib import pyplot as plt

Here, I just try to force matplotlib to use the correct plotting backend. Hopefully, it would work correctly after this. However, it is difficult to be sure as this seems to be an environment issue.

If this does not work, then could you also please try to open your python console and run:

import matplotlib
matplotlib.get_backend()

and let me know the output. Also, what version of matplotlib are you using?

@liu3zhenlab
Copy link
Author

matplotlib 3.0.0 was used.

@mnshgl0110
Copy link
Member

Did it work after adding those two lines?

@mnshgl0110
Copy link
Member

And what was the output of matplotlib.get_backend()?

@liu3zhenlab
Copy link
Author

'agg'

@liu3zhenlab
Copy link
Author

I am working on that. Will update the result later.

@liu3zhenlab
Copy link
Author

liu3zhenlab commented Jul 1, 2020

Not familiar with Python. some error occurred after modifying the script:

File "syri/syri/bin/plotsr", line 155
matplotlib.use('Qt5Agg')
^
TabError: inconsistent use of tabs and spaces in indentation

@mnshgl0110
Copy link
Member

Ok. In that case, please try with this version of plotsr https://github.com/schneebergerlab/syri/blob/V1.3/syri/bin/plotsr

@liu3zhenlab
Copy link
Author

Thank Manish. But the problem remains.

Traceback (most recent call last):
File "/homes/liu3zhen/software/syri/syri/bin/plotsr", line 156, in
plt.switch_backend('Qt5Agg')
File "/homes/liu3zhen/.conda/envs/syri/lib/python3.5/site-packages/matplotlib/pyplot.py", line 221, in switch_backend
newbackend, required_framework, current_framework))
ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running

@mnshgl0110
Copy link
Member

That's not good.
Maybe, the last thing to check would be to open a python console and run:

from matplotlib import pyplot as plt
plt.switch_backend('Qt5Agg')

I would expect that this would give the same error again. If so, then we can be sure that this is an environment issue. Maybe, you can also try deleting and reinstalling matplotlib.

Unfortunately, I am out of better ideas right now. I would try to find a solution and would let you know if I find something helpful.

@liu3zhenlab
Copy link
Author

liu3zhenlab commented Jul 1, 2020

My lab member Ha Le suggested using "cario" rather than "Qt5Agg" as the matplotlib backend. It solved the problem. I have successfully produced the figure. Thanks a lot for your time and rapid responses.

@mnshgl0110
Copy link
Member

That's great. Thanks for sharing the solution.

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

2 participants