简体   繁体   English

matplotlib 已安装 - ModuleNotFoundError: No module named 'matplotlib'

[英]matplotlib installed - ModuleNotFoundError: No module named 'matplotlib'

I installed matplotlib.我安装了 matplotlib。

But when i try to import it into my project import matplotlib.pyplot as plt但是当我尝试将它导入到我的项目中时,将 matplotlib.pyplot 作为 plt

it say ModuleNotFoundError: No module named 'matplotlib'它说 ModuleNotFoundError: No module named 'matplotlib'

pip list gives me: matplotlib 3.2.1 pip 列表给了我:matplotlib 3.2.1

I am using Atom我正在使用原子

I tried reinstalling matplotlib several times and every solution i could find on google, nothing seems to work.我尝试重新安装 matplotlib 几次,我可以在谷歌上找到的每个解决方案,似乎没有任何效果。

A lot of things can make your code not to find the module, one of the common problem is having multiple python versions installed on your computer.很多事情都会使您的代码找不到模块,其中一个常见问题是您的计算机上安装了多个 python 版本。 Using a virtual environment to manage the project will help fix such problems on your project.使用虚拟环境管理项目将有助于解决项目中的此类问题。

  • On your project directory, create a virtual environment with venv在您的项目目录中,使用 venv 创建一个虚拟环境
    python3 -m venv workspace
    workspace is the name of the environment, you can give it any name you want工作区是环境的名称,你可以给它任何你想要的名字

  • Activate the virtual environment激活虚拟环境
    On PC use this code在 PC 上使用此代码
    workspace\Scripts\activate.bat
    On Mac/Linux在 Mac/Linux 上
    source venv/bin/activate

  • Install matplotlib in the virtual environment and run your code在虚拟环境中安装 matplotlib 并运行你的代码

When you are done you could deactivate the environment with this code完成后,您可以使用此代码停用环境
deactivate

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:即使安装了包,也没有名为“matplotlib”的模块 - ModuleNotFoundError: No module named 'matplotlib' even though the package is installed jupyter ModuleNotFoundError:没有名为 matplotlib 的模块 - jupyter ModuleNotFoundError: No module named matplotlib 没有安装名为matplotlib且带有matplotlib的模块python 2.7 - No module named matplotlib with matplotlib installed Python 2.7 ModuleNotFoundError:没有名为“matplotlib.pyplot”的模块 - ModuleNotFoundError: No module named 'matplotlib.pyplot' ModuleNotFoundError: No module named 'matplotlib' - Deploying Issue of Jupyter Project on Heroku - ModuleNotFoundError: No module named 'matplotlib' - Deploying Issue of Jupyter Project on Heroku 正在读取一条错误消息:ModuleNotFoundError:没有名为“ matplotlib.artist”的模块 - Getting an error that reads: ModuleNotFoundError: No module named 'matplotlib.artist' 问:ModuleNotFoundError:没有名为“ matplotlib.pyplot”的模块,等等 - Q: ModuleNotFoundError: No module named 'matplotlib.pyplot', etc 尝试在Azure中使用matplotlib时出现“ ModuleNotFoundError:没有名为'tkinter'的模块” - “ModuleNotFoundError: No module named 'tkinter'” when trying to use matplotlib in Azure ModuleNotFoundError:matplotlib 导入时没有名为“numpy.core._multiarray_umath”的模块 - ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' on matplotlib import Jupyter Notebook:ModuleNotFoundError:没有名为“matplotlib.pylot”的模块 - Jupyter Notebook: ModuleNotFoundError: No module named 'matplotlib.pylot'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM