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

patched matplotlib backend use, compatability for jupyter notebook #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dcxSt
Copy link

@dcxSt dcxSt commented Jan 30, 2023

I copied this issue (which I opened) below.

Jupyter notebook crashes upon importing spinmob because I don't have the correct backed qtagg. I suspect this is because I'm using an ARM machine and this particular mpl backend hasn't yet been ported.

Screen Shot 2023-01-30 at 5 18 27 PM

I got around this by cloning the repo and importing it locally, and patching it with a try statement. Here is the piece of code causing the error, in the package's __init__

import os           as _os
import sys          as _sys
import matplotlib   as _mpl; _mpl.use('qtagg')

import pylab

Here is a suggested patch:

import os           as _os
import sys          as _sys
import matplotlib   as _mpl

try: 
    _mpl.use('qtagg')
except Exception as e: 
    print("WARNING: not using qtagg. This might be because you don't have the latest version either Spinmob or other dependencies. Try updating your libraries. This issue has also been known to occur in Jupyter Notebooks and possibly on ARM silicon architecture. Proceeding without a backend.")
    print(f"\nThe error that would have been raised is:\n{e}\n")
    pass

import pylab

I put the statement in question it into a try-catch block and issued a warning. Would you like me to submit a PR? Now the statement reads

Screen Shot 2023-01-30 at 5 26 40 PM

Extra info:
Before cloning and modifying the source, I first pip-installed the latest version of spinmob and have tried to install all the mpl's backends.

@dcxSt
Copy link
Author

dcxSt commented Feb 2, 2023

I printed a warning, but without using the official warning control.

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

Successfully merging this pull request may close these issues.

1 participant