简体   繁体   中英

Visual studio code: "matplotlib" is not accessed Pylance

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: 在此处输入图像描述

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

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.

Restarting vsCode after a library installation is underrated. it solved my problem with accesssing urllib3 after an installation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM