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

Error when using srw_python in Spyder (with IPython Console) #29

Open
wcgrizolli opened this issue Aug 7, 2020 · 0 comments
Open

Error when using srw_python in Spyder (with IPython Console) #29

wcgrizolli opened this issue Aug 7, 2020 · 0 comments

Comments

@wcgrizolli
Copy link

Hi all

There a problem with the uti_plot_matplotlib.py that prevents me from using SRW in Spyder (currently using Spyder 4.1.4). I actually think the problem is with IPython, which is the new console for Spyder for a while now.

This is the error in Spyder:

Traceback (most recent call last):
  File "C:\Users\LabviewID\Miniconda3\lib\site-packages\oasys_srw\uti_plot.py", line 57, in uti_plot_init
    _backend = uti_plot_matplotlib.Backend(backend, fname_format)
  File "C:\Users\LabviewID\Miniconda3\lib\site-packages\oasys_srw\uti_plot_matplotlib.py", line 26, in __init__
    backend = self._init_ipython(backend)
  File "C:\Users\LabviewID\Miniconda3\lib\site-packages\oasys_srw\uti_plot_matplotlib.py", line 592, in _init_ipython
    if backend == uti_plot.DEFAULT_BACKEND:
NameError: name 'uti_plot' is not defined
QT5Agg: unable to import specified backend (or its dependency); no plots
Traceback (most recent call last):

I'm using trough Oasys, but I tracked down the problem to uti_plot_matplotlib.py. I found a workaround that I want to suggest. The line

get_ipython().magic('matplotlib ' + b)

is replaced by

if any('SPYDER' in name for name in os.environ):
    pass
else:
    get_ipython().magic('matplotlib ' + b)
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

1 participant