No module named scipy.stats - Why despite scipy being installed

I accidentally caused this issue by naming one of my scipy test programs "scipy.py". Of course, this makes any "import scipy" in this directory import my test program, not the system library, in turn resulting in lots of errors like:

ImportError: No module named stats

It's embarrassing how long it took me to figure this out!


pip install --upgrade --force-reinstall scipy


I had a similar issue with Python 3.4 on my Windows 7 machine. I had to update my scipy package 'pip install --upgrade scipy'


I think scipy is the way to go. Probably you have a simple namespace visibility problem. since stats is itself a module you first need to import it, then you can use functions from scipy.stats

import scipy
import scipy.stats
#now you can use
scipy.stats.poisson
#if you want it more accessible you could do what you did above
from scipy.stats import poisson
#then call poisson directly
poisson

Tags:

Python

Scipy