简体   繁体   中英

matplotlib installed - ModuleNotFoundError: No module named 'matplotlib'

I installed matplotlib.

But when i try to import it into my project import matplotlib.pyplot as plt

it say ModuleNotFoundError: No module named 'matplotlib'

pip list gives me: 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.

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. 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
    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
    workspace\Scripts\activate.bat
    On Mac/Linux
    source venv/bin/activate

  • Install matplotlib in the virtual environment and run your code

When you are done you could deactivate the environment with this code
deactivate

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