Attributeerror: module ‘scipy’ has no attribute ‘stats’

It’s understandable to be frustrated when you encounter errors like attributeerror: module 'scipy' has no attribute 'stats' when you’re working on a Python project. But don’t worry, as in this article we will show you how to solve this error.

The error “attributeerror: module 'scipy' has no attribute 'stats'” is a Python error, which means that the stats attribute is being accessed by Python code in the scipy package but it doesn’t exist there.

This may be due to the fact that stats were deprecated or renamed in the latest version of scipy, or it may have been due to the incorrect installation of the scipy package.

Anyway, before we begin our tutorial, have a quick overview of Python and AttributeError.

What is Python?

Python is one of the most popular programming languages. It is used for developing a wide range of applications. It is a high-level programming language that is usually used by developers nowadays due to its flexibility.

What is AttributeError?

An attributeerror is an error that appears in our Python codes when we try to access an attribute of a non-existent object. In addition, this occurs when we attempt to perform non-supported operations.

Now that we understand this error and even what Python and an AttributeError are, let’s move on to our “how to fix this error” tutorial.

How to solve “module ‘scipy’ has no attribute ‘stats’” in Python

In order to fix the error attributeerror: module 'scipy' has no attribute 'stats' in Python, you have to do the following:

  1. Verify the installation of the scipy package.

    Make sure that you have properly installed the scipy package on your system. To check, open your command prompt and enter the command pip show scipy, or you may enter it in your terminal.

    The pip show scipy the command will display information about the scipy package, including its version and location.


    C:\Users\path>pip show scipy
    Name: scipy
    Version: 1.9.1
    Summary: SciPy: Scientific Library for Python
    License: BSD
    Location: c:\users\path\path\lib\site-packages
    Requires: numpy
    Required-by: datashader, gensim, scikit-image, scikit-learn, statsmodels

  2. Verify if you’re using the correct scipy package.

    As mentioned above, stats have been deprecated or renamed in different versions of scipy. Hence, it is important to verify if you’re using the correct scipy package.

    To do so, you can try to upgrade or downgrade the package to the version that stats includes.

  3. Double-check your spelling or check for typos.

    Make sure to always check your spelling and check for typos, as there are times that errors occur due to misspellings or typos.

  4. Change your import statement.

    Instead of importing it like this:

    import scipy

    or this:

    import scipy.stats

    Import it like this:

    import scipy
    from scipy import stats

Alternative Solution

If the above solution doesn’t solve the issue, try this alternative solution: Reinstall the scipy package.

To reinstall the scipy package, follow the steps below:

1. Uninstall the scipy package.

To uninstall the scipy package, input the command pip uninstall scipy in your terminal or command prompt.

After inputting the pip uninstall scipy command, results will come out, and this question will also appear (Proceed (Y/n)?). Once that appears, just type Y, then click the Enter key.


C:\Users\path>pip uninstall scipy
Found existing installation: scipy 1.9.1
Uninstalling scipy-1.9.1:
Would remove:
Proceed (Y/n)? y
Successfully uninstalled scipy-1.9.1


If you’re using Python 3, use the command pip3 uninstall scipy.
If you’re using Jupyter Notebook, use the command !python -m pip uninstall scipy --yes.
If you’re using Anaconda, use the command conda remove scipy.

2. Install the scipy package.

To install the scipy package, use the command pip install scipy. This command will install the latest version of the scipy package.


If you’re using Python 3, use the command pip3 install scipy.
If you’re using Jupyter Notebook, use the command !pip install scipy.
If you’re using Anaconda, use the command conda install -c anaconda scipy.


In conclusion, the Python error attributeerror: module 'scipy' has no attribute 'stats' can be easily solved by either updating the version of your scipy package, reinstalling it, or changing your import statement.

By following the guide above, there’s no doubt that you’ll be able to resolve this error quickly and without a hassle.

I think that’s all for today, ITSOURCECODERS! We hope you’ve learned a lot from this. If you have any questions or suggestions, please leave a comment below, and for more attributeerror tutorials in Python, visit our website.

Thank you for reading!

Leave a Comment