Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jonathan Grieve
Treehouse Moderator 91,228 PointsMatplotlib outside of Jupyter
Does Matploib require using Jupyter to work?
I've been trying to run scripts built in Jupyter in the command line but pyplot doesn't seem to be recogised.
In fact, despite installing matplotlib with pip, sometimes that doesn't seem to be recognised either.
$ python old_faithful.py
Traceback (most recent call last):
File "old_faithful.py", line 2, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
Is this possible or should I stick with Jupyter.
1 Answer

Alexander Davison
65,468 PointsNo, you can use Matplotlib pretty much anywhere, not just in Jupyter.
I'm using Ubuntu and I successfully installed Matplotlib using the command pip3 install matplotlib
. Did you use pip
instead of pip3
?
Also make sure that you are using Python 3 on your local computer (or elsewhere). In the command line, type python3
instead of python
.
Jonathan Grieve
Treehouse Moderator 91,228 PointsJonathan Grieve
Treehouse Moderator 91,228 PointsThis is interesting because I have Python3 setup on both my systems (Windows 10) and they show up as the latest version of Python 3.
I ended up trying both pip and pip3 and even though the terminal reports installations when I run the script it comes up ModuleNotFound, so there's some funny stuff going on, I reckon.
Jonathan Grieve
Treehouse Moderator 91,228 PointsJonathan Grieve
Treehouse Moderator 91,228 PointsThanks Alexander,
I've just managed to generate a figure on my laptop which confirms that it works. I already had the packages I needed so I was able to call the file with simply the
python
command. It does mean there's something wrong with my installation on the PC though that's preventing the images from being created.Will investiate :)