AllenDowney / ThinkStats2

Text and supporting code for Think Stats, 2nd Edition
http://allendowney.github.io/ThinkStats2/
GNU General Public License v3.0
4.01k stars 11.23k forks source link

Missing Matplotlib #210

Closed TonyArmstrong closed 8 months ago

TonyArmstrong commented 9 months ago

I downloaded the zip containing everything in the repo so I'd have it locally (more convenient). I ran nsfg.py and got the following error and traceback: Traceback (most recent call last): File "/Users/anthonyarmstrong/thinkstats/ThinkStats2-master/code/nsfg.py", line 10, in import thinkstats2 File "/Users/anthonyarmstrong/thinkstats/ThinkStats2-master/code/thinkstats2.py", line 32, in import thinkplot File "/Users/anthonyarmstrong/thinkstats/ThinkStats2-master/code/thinkplot.py", line 9, in import matplotlib ModuleNotFoundError: No module named 'matplotlib'

I am using a venv and I'm sure that I have matplotlib installed. Here's the relevant pip freeze: matplotlib==3.8.0 matplotlib-inline==0.1.6

I also did a sanity check and it seems that matplotlib seems to be installed and working well.

Can anyone tell me what might be wrong?

AllenDowney commented 9 months ago

If pip says matplotlib is installed and Python can't find it, the mostly likely explanation is that Python is not running in the same environment pip is looking in. Another possibility is that Python's search path is not set right. Both would be problems with your development environment.

I understand that running locally is more convenient, but not if it means spending time debugging your installation!

TonyArmstrong commented 8 months ago

This was one of those nettlesome gremlins. I reinstalled everything in the virtual environment and now seems all is working well.

AllenDowney commented 8 months ago

Glad you got it working!