Skip to content

MAINT: replace distutils LooseVersion #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

fernando-duarte
Copy link

Title:
Fix distutils deprecation warning in Python 3.13 by switching to packaging.version


Background

In Python 3.13 the distutils.version classes are deprecated. As a result, importing pandas-datareader emits:

DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
PANDAS_0230 = PANDAS_VERSION >= LooseVersion("0.23.0")

The warning originates in
pandas_datareader/compat/__init__.py
which currently does:

from distutils.version import LooseVersion

PANDAS_0230 = PANDAS_VERSION >= LooseVersion("0.23.0")

Changes

  • Remove the distutils.version import
  • Add from packaging.version import Version
  • Compare pandas version using Version(...) instead of LooseVersion(...)
--- a/pandas_datareader/compat/__init__.py
+++ b/pandas_datareader/compat/__init__.py
@@ -1,5 +1,5 @@
- from distutils.version import LooseVersion
+ from packaging.version import Version

 PANDAS_0230 = PANDAS_VERSION >= Version("0.23.0")

@fernando-duarte fernando-duarte deleted the codex/fix-distutils-deprecation-warning-in-python-3.13 branch May 22, 2025 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant