{"id":7756,"library":"statistics","title":"statistics (PyPI backport for Python 2.x)","description":"This PyPI package provides a backport of the Python 3.4 `statistics` module for Python 2.x environments. It offers functions for calculating mathematical statistics of numeric (real-valued) data, mirroring the functionality introduced in Python 3.4's standard library. For Python 3.4 and newer, the `statistics` module is built directly into Python and this PyPI package is not needed and generally should not be installed.","status":"abandoned","version":"1.0.3.5","language":"en","source_language":"en","source_url":"https://github.com/digitalemagine/py-statistics","tags":["statistics","math","numeric","python2","backport","deprecated"],"install":[{"cmd":"pip install statistics","lang":"bash","label":"For Python 2.x environments (not recommended for Python 3+)"}],"dependencies":[],"imports":[{"symbol":"statistics","correct":"import statistics"}],"quickstart":{"code":"import statistics\n\ndata = [1.5, 2.5, 3.5, 4.5, 5.5]\n\nmean_value = statistics.mean(data)\nmedian_value = statistics.median(data)\nmode_value = statistics.mode(data)\nstdev_value = statistics.stdev(data)\n\nprint(f\"Mean: {mean_value}\")\nprint(f\"Median: {median_value}\")\nprint(f\"Mode: {mode_value}\")\nprint(f\"Standard Deviation: {stdev_value}\")","lang":"python","description":"Calculate basic statistics (mean, median, mode, standard deviation) from a list of numeric data. This example code uses the `statistics` module, which is built-in for Python 3.4+ and provided by the PyPI package for Python 2.x. It's assumed the appropriate version of Python (3.4+ built-in or Python 2 with the PyPI package) is in use."},"warnings":[{"fix":"For Python 3.4 and later, *do not* `pip install statistics`. Simply `import statistics` to use the built-in standard library module.","message":"The PyPI `statistics` package is a backport specifically for Python 2.x environments, mimicking Python 3.4's built-in module. It has not been updated since 2014 and Python 2.x reached End-of-Life in January 2020. Installing this package on Python 3.4+ is generally incorrect and can lead to unexpected behavior, missing features, or module conflicts, as Python 3.4+ includes the `statistics` module in its standard library.","severity":"breaking","affected_versions":"All versions of the PyPI package on Python 3.4+"},{"fix":"Ensure you are using the standard library `statistics` module by avoiding `pip install statistics` on Python 3. If it was installed, uninstall it with `pip uninstall statistics`.","message":"The PyPI `statistics` package only provides features up to Python 3.4's `statistics` module. If installed in a Python 3 environment, it will *shadow* the standard library module, meaning newer functions (e.g., `fmean`, `geometric_mean`, `quantiles` from Python 3.8+; `covariance`, `correlation` from Python 3.10+) will be unavailable or raise `AttributeError`.","severity":"gotcha","affected_versions":"All versions of the PyPI package when used with Python 3.5+"},{"fix":"Migrate your project to Python 3.4+ and use its built-in `statistics` module.","message":"This package's primary purpose was to provide `statistics` functionality to Python 2.x, which is now an unsupported and End-of-Life version of Python. Using this package means relying on an unmaintained codebase for an unsupported Python version.","severity":"deprecated","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Uninstall the PyPI package: `pip uninstall statistics`. Then, ensure your Python environment is 3.8 or newer and try again; `fmean` will be available from the built-in module.","cause":"You have likely installed the PyPI `statistics` backport on a Python 3 environment, which only includes features up to Python 3.4's standard library module. `fmean` was introduced in Python 3.8.","error":"AttributeError: module 'statistics' has no attribute 'fmean'"},{"fix":"For Python 2.x or Python < 3.4, install the PyPI package: `pip install statistics`. For Python 3.4+, this error should not occur, as `statistics` is built-in; verify your Python version and environment.","cause":"You are likely running Python 2.x or an older Python 3 version (prior to 3.4) and have not installed the PyPI `statistics` package.","error":"ModuleNotFoundError: No module named 'statistics'"},{"fix":"If on Python 3.8+, uninstall the PyPI `statistics` package (`pip uninstall statistics`) to ensure you're using the built-in, more recent version. If on an older Python version, you may need to manually calculate or upgrade your Python version to access newer features.","cause":"This error occurs in older versions of `statistics.median_grouped` (like the Python 3.4 implementation in the PyPI backport) when attempting to pass the `interval` argument, which was introduced in Python 3.8. It indicates you're using an older version of the `statistics` module.","error":"TypeError: ('median_grouped() takes at most 2 arguments (3 given)',)"}]}