Ausnahme im PyCharm-Debug-Modus, aber nicht im Ausführungsmodus (Seaborn, Matplotlib)Python

Python-Programme
Anonymous
 Ausnahme im PyCharm-Debug-Modus, aber nicht im Ausführungsmodus (Seaborn, Matplotlib)

Post by Anonymous »

Ich verwende
  • PyCharm 2021.2.3 Community Edition
  • Python-Interpreter 3.10.0
  • matplotlib 3.5.0
  • seaborn 0.11.2
  • numpy 1.21.4
  • pandas 1.3.4
  • PySimpleGUI 4.55.1
Wenn ich das folgende Skript ausführe, ist es im Ausführungsmodus in Ordnung, aber im Debug-Modus löst es eine Ausnahme aus. Hier ist das Skript:

Code: Select all

import numpy as np
import pandas as pd
import PySimpleGUI as sg
import seaborn as sns

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure

def init_data():
r1 = np.random.rand(5, 4)
columns = [f"var{i}" for i in range(1, 5)]
df = pd.DataFrame(r1, columns=columns)
df.insert(0, 'year', range(2021, 2026))
df.insert(1, 'scenario', 'test1')
ldf = pd.melt(df, id_vars=['year', 'scenario'], value_vars=columns, var_name='percentile', value_name='carbon')
return ldf

def draw_figure(canvas, figure):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg

# define the window layout
layout = [[sg.Text('Plot test')],
[sg.Canvas(key='-CANVAS-')],
[sg.Button('Ok')]]

# create the form and show it without the plot
window = sg.Window('Testing seaborn in PySimpleGUI', layout, finalize=True,
element_justification='center', font='Helvetica 18')

figure = Figure()
ax = figure.subplots()
sns.lineplot(x='year', y='carbon', hue='percentile', data=init_data(), ax=ax)

# add the plot to the window
fig_canvas_agg = draw_figure(window['-CANVAS-'].TKCanvas, figure)

event, values = window.read()

window.close()
Und hier ist der Stacktrace:

Code: Select all

Traceback (most recent call last):
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\getlimits.py", line 384, in __new__
dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.2.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1483, in _exec
pydev_imports.execfile(file, globals, locals)  # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2021.2.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/OneDrive/OneDrive - Louise Pryor &  Co Ltd/Actuarial/Carbon/Carbon/seaborntest.py", line 39, in 
sns.lineplot(x='year', y='carbon', hue='percentile', data=init_data(), ax=ax)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\_decorators.py", line 46, in inner_f
return f(**kwargs)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\relational.py", line 710, in lineplot
p.plot(ax, kwargs)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\relational.py", line 557, in plot
self._add_axis_labels(ax)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\seaborn\_core.py", line 1194, in _add_axis_labels
x_visible = any(t.get_visible() for t in ax.get_xticklabels())
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 75, in wrapper
return get_method(self)(*args, **kwargs)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axis.py", line 1249, in get_ticklabels
return self.get_majorticklabels()
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axis.py", line 1201, in get_majorticklabels
ticks = self.get_major_ticks()
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axis.py", line 1371, in get_major_ticks
numticks = len(self.get_majorticklocs())
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axis.py", line 1277, in get_majorticklocs
return self.major.locator()
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\ticker.py", line 2113, in __call__
vmin, vmax = self.axis.get_view_interval()
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axis.py", line 1987, in getter
return getattr(getattr(self.axes, lim_name), attr_name)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 781, in viewLim
self._unstale_viewLim()
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 776, in _unstale_viewLim
self.autoscale_view(**{f"scale{name}": scale
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 2932, in autoscale_view
handle_single_axis(
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\axes\_base.py", line 2895, in handle_single_axis
x0, x1 = locator.nonsingular(x0, x1)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\ticker.py", line 1654, in nonsingular
return mtransforms.nonsingular(v0, v1, expander=.05)
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\transforms.py", line 2880, in nonsingular
if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
File "C:\Users\drlou\AppData\Local\Programs\Python\Python310\lib\site-packages\numpy\core\getlimits.py", line 387, in __new__
dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Hat das jemand schon einmal gesehen oder hat er irgendwelche Ideen?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post