Cannot use scipy.stats

expanding on my comment (to have a listed answer).

Scipy, as many other large packages, doesn’t import all modules automatically. If we want to use the subpackages of scipy, then we need to import them directly.

However, some scipy subpackages load other scipy subpackages, so for example importing scipy.stats also imports a large number of the other packages. But I never rely on this to have the subpackage available in the namespace.

In many packages that use scipy, the preferred pattern is to import the subpackages to have them available by their names, for example:

>>> from scipy import stats, optimize, interpolate


>>> import scipy
>>> scipy.stats
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'stats'
>>> scipy.optimize
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'optimize'

>>> import scipy.stats
>>> scipy.optimize
<module 'scipy.optimize' from 'C:\Python26\lib\site-packages\scipy\optimize\__init__.pyc'>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)