From 100e4e19ddba6a48e5ff7a52460aa50753c1154e Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:25:06 -0700 Subject: [PATCH 1/2] BUG: Allow show_versions to work for any module that raises an exception --- pandas/util/_print_versions.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/pandas/util/_print_versions.py b/pandas/util/_print_versions.py index c4fec39594407..e57c8c0953e51 100644 --- a/pandas/util/_print_versions.py +++ b/pandas/util/_print_versions.py @@ -45,7 +45,7 @@ def _get_sys_info() -> dict[str, JSONSerializable]: language_code, encoding = locale.getlocale() return { "commit": _get_commit_hash(), - "python": ".".join([str(i) for i in sys.version_info]), + "python": platform.python_version(), "python-bits": struct.calcsize("P") * 8, "OS": uname_result.system, "OS-release": uname_result.release, @@ -73,30 +73,23 @@ def _get_dependency_info() -> dict[str, JSONSerializable]: "setuptools", "pip", "Cython", - # test - "pytest", - "hypothesis", # docs "sphinx", - # Other, need a min version - "blosc", - "feather", - "xlsxwriter", - "lxml.etree", - "html5lib", - "pymysql", - "psycopg2", - "jinja2", # Other, not imported. "IPython", - "pandas_datareader", ] + # Optional dependencies deps.extend(list(VERSIONS)) result: dict[str, JSONSerializable] = {} for modname in deps: - mod = import_optional_dependency(modname, errors="ignore") - result[modname] = get_version(mod) if mod else None + try: + mod = import_optional_dependency(modname, errors="ignore") + except Exception: + # Dependency conflicts may cause a non ImportError + result[modname] = "N/A" + else: + result[modname] = get_version(mod) if mod else None return result From 22986c459e2941eceba8961957936d8e02e7d115 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 26 Jun 2024 15:26:35 -0700 Subject: [PATCH 2/2] Remove setuptools --- pandas/util/_print_versions.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/util/_print_versions.py b/pandas/util/_print_versions.py index e57c8c0953e51..7e18ebe40cfa8 100644 --- a/pandas/util/_print_versions.py +++ b/pandas/util/_print_versions.py @@ -70,7 +70,6 @@ def _get_dependency_info() -> dict[str, JSONSerializable]: "pytz", "dateutil", # install / build, - "setuptools", "pip", "Cython", # docs