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

Debugging matplotlib in VSCode encounters TypeError: 'NoneType' object is not callable #959

Closed
Tian-Jionglu opened this issue Jun 19, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Tian-Jionglu
Copy link

  • VS Code Version: 1.68.1;
  • Python Extension Version: v2022.8.0;
  • OS Version: MacOS 12.4;
  • Python Version: 3.10.4;
  • Matplotlib Version: 3.5.2;
  • Pandas Version: 1.3.4 ( 1.4.2 also tested);

Steps to Reproduce:

  1. snippet to reproduce the problem:
    import matplotlib.pyplot as plt
    import pandas as pd
    
    data = pd.DataFrame()
    
    plt.pie([1, 2, 3, 5])
    plt.show()
    
    It returns TypeError: 'NoneType' object is not callable, when using debugging (F5) in VSCode.
  2. when pandas clauses are commented, the error flees:
    import matplotlib.pyplot as plt
    # import pandas as pd
    
    # data = pd.DataFrame()
    
    plt.pie([1, 2, 3, 5])
    plt.show()
    

The initial code [1] runs well in other IDE. I suppose there is something wrong in Python Extension.

And here is the Traceback:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/my/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/lib/python/debugpy/launcher/__main__.py", line 97, in <module>
    main()
  File "/Users/my/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/lib/python/debugpy/launcher/__main__.py", line 53, in main
    launcher.connect(host, port)
  File "/Users/my/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/lib/python/debugpy/launcher/../../debugpy/launcher/__init__.py", line 34, in connect
    sock.connect((host, port))
ConnectionRefusedError: [Errno 61] Connection refused
Backend MacOSX is interactive backend. Turning interactive mode on.

There are similar issues sumerc/yappi#97 and matplotlib/matplotlib#22333.

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Jun 19, 2022
@bschnurr
Copy link
Member

still having this issue?
on windows it seems to work.

you have selected the correct python environment?
what version of pylance extension do you have installed?

@int19h
Copy link
Contributor

int19h commented Jun 21, 2022

@BSchurr This is a debugger issue; the error message is occurring at runtime.

@fabioz, going by the referenced issues in other repos, this has something to do with PyFrame_FastToLocals; it appears that we must be using PyEval_GetLocals on Python 3.10+ instead.

@int19h int19h added bug Something isn't working and removed waiting for response triage-needed labels Jun 21, 2022
@fabioz
Copy link
Collaborator

fabioz commented Jun 23, 2022

I'll investigate.

@fabioz
Copy link
Collaborator

fabioz commented Jun 23, 2022

@Tian-Jionglu This seems like the same issue in #801.

It seems pandas 1.4.3 still wasn't released with a newer version of cython (so, users are still seeing this):
pandas-dev/pandas#47429
pandas-dev/pandas#46610

@fabioz
Copy link
Collaborator

fabioz commented Jun 23, 2022

Note that unlike yappi we don't call PyFrame_FastToLocals anywhere -- we do call PyFrame_LocalsToFast but only if the user does an evaluation or changes a local variable, so, the fix applied there isn't applicable here.

The real fix is having a pandas/numpy toolchain which is built with a fixed version of cython so that tracing can be installed while using those and that's outside of the scope of the debugger, so, I'm closing this issue -- see comments in #801.

p.s.: this only affects Mac OS.

@fabioz fabioz closed this as completed Jun 23, 2022
@Tian-Jionglu
Copy link
Author

@fabioz Thanks for explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants