Visual studio code: "matplotlib" is not accessed Pylance

Issue

I get the error in the title when I try to import matplotlib. Please I have been searching for 3 hours and still no solution.I’ve tried source activate base changing the interpreter, I have updated to latest matplotlib. and I have tried echo "backend : TkAgg" > ~/.matplotlib/matplotlibrc but none of these works. But numpy works but for some reason matplotlib does not. any help is appreciated.

terminal message:

Traceback (most recent call last):
  File "/Users/MacBook/python/code/stats.py", line 2, in <module>
    import matplotlib 
ModuleNotFoundError: No module named 'matplotlib'
(base) MacBook-Air:~ MacBook$ 

My matplotlib version:
enter image description here

On another note: when trying to import matplotlib I see a matplotlib_inline but not matplotlib on VS CODE

Solution

Since You already installed matplotlib and since I had a similar problem, heres what I did:

1.) change your python interpreter: In VSCODE there’s usually a "recommended" interpreter that they will recommend, try that one. If that dosen’t work try to use the interpreter with "conda" in the name.

2.) This is the most important but overlooked step: RESTART your VS code to see the changes. bring up the command palate via cmd + shift + p, then type in "reload" and a "reload window" should pop up, click on it to reload.

3.) once reloaded you should be able to import matplotlib now.

Answered By – kevin

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published