Unable to use MatPlotLib in Python Files
-
Despite having installed it, and MatPlotLib seeming to work fine in Thonny and IDLE, I am unable to use MatPlotLib at all in Notepad++. Everytime I do, I get a ModuleNotFoundError.
It should be noted that other modules I’ve used, like NumPy and math, are completely fine. It’s just MatPlotLib. I’ve tried uninstalling MatPlotLib, reinstalling it, updating it, updating pip, using pip install commands within Notepad++, restarting Notepad++, restarting my computer, and nothing has worked. What’s going on?
-
How are you running the python file in Notepad++? Are you using a Run menu entry? Or are you using NppExec Plugin? Or some other plugin to run it? Or some other way?
Depending on what your answer is, the debug process might be slightly different.
(It should be noted that while I am a casual user of Python, I am not an expert at library issues. But there are a couple of the regulars here who are probably more familiar with library issues, and once they know how you’re running Python through Notepad++, they might be able to help you figure out why it’s behaving differently than via Thonny or IDLE.)
-
@PeterJones I’ve used both the Run menu entry, and the NppExec plugin, and have gotten the same result for both. I’m willing to use either.
-
@bungoscrungus said in Unable to use MatPlotLib in Python Files:
@PeterJones I’ve used both the Run menu entry, and the NppExec plugin, and have gotten the same result for both. I’m willing to use either.
Okay, that will be helpful for the Notepad++ regulars who are also Python experts.
That doesn’t give my limited experience any solid clues. My only guesses would be to check whether there are environment variables that are set differently from within Notepad++'s NppExec console vs the env vars that Thonny or IDLE see. But that’s a pretty lame guess; hopefully one of the others will be able to give you more.
Given the time zone differences involved, it may be their tomorrow – or yours – before they have a chance to chime in.
-
The other ideas I’ve had:
- if you can share the path to python.exe, the path to NumPy, and the path to MatPlotLib, that might help – if one is in an “unusual” location relative to the others, then some behind-the-scenes difference might not allow the Notepad++ run of python to see the library
- if you can print out your
sys.path
entries under IDLE vs under Notepad++, that is probably useful information as well - it would probably be good for you to see whether you get it working or the ModuleNotFound error if you run the script from the windows command line (cmd.exe or powershell). If it doesn’t run under the standard command line, then it’s probably a directory/sys.path issue where Thonny and IDLE are better at guessing alternative locations for libraries; if it does run under command line, then I’m out of my depth
-
@PeterJones I didn’t think of checking the command line, thanks! The error appeared there, too. This might be the first time I’ve been glad to see a module error – thank you!
It turns out a program I had also had python.exe, and Notepad++ was using that Python instead. Uninstalled the program, MatPlotLib works perfectly! Thank you!