debugger throws error, running script doesn't - pandas boxplot

Viewed 84

Title is pretty self explanatory. Here is a minimal reproducible example (just make a .xlsx file with a column id, a column nb_inf and another called Grantham and some data (integers)).

import matplotlib.pyplot as plt
import pandas as pd

def loader() -> pd.DataFrame:
    df = pd.read_excel("your_file.xlsx", "Feuil1")
    df = df.set_index('id')

    return df

if __name__ == "__main__":
    df: pd.DataFrame = loader()
    for column in df.columns:
        if "Grantham" in column:
            print(column)
            df.boxplot(column=column, by='nb_inf', figsize=(5, 6))
            plt.savefig(f"boxplots/{column}.png")
            plt.close()

Running it through the Run command works perfectly well. But running it with the debugger raises the error TypeError: 'NoneType' object is not callable.

I'm using Python 3.10.2 and PyCharm 2022.1.3 (Community Edition)

More details about my PyCharm build:

Build #PC-221.5921.27, built on June 21, 2022
Runtime version: 11.0.15+10-b2043.56 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2030M
Cores: 16
Non-Bundled Plugins:
    com.chesterccw.excelreader (2022.1.3)
1 Answers

Works in VSCode, both in debug and standard execution mode. Have you considered switching to a better IDE than PyCharm such as VSCode?

On a more serious note, check out your debugging default option in PyCharm; it's likely there is an option you don't want there...

Related