From 31cdfdc6749cea4d722e11dc351b91673cd6be6d Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Wed, 22 Oct 2025 20:19:19 +0200 Subject: [PATCH 1/7] Improve import error message for opt deps Updated error message to include 'your preferred package manager' to include other package/project managers. --- pandas/compat/_optional.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index 42bd965e88c86..0bc31a9a88418 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -152,7 +152,8 @@ def import_optional_dependency( msg = ( f"`Import {install_name}` failed. {extra} " - f"Use pip or conda to install the {install_name} package." + f"Use pip, conda, or your preferred package " + f"manager to install the {install_name} package." ) try: module = importlib.import_module(name) From 5762535d7b5bd612f9869a19ee13aa51046d4282 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Wed, 22 Oct 2025 20:22:09 +0200 Subject: [PATCH 2/7] Update error message in test --- pandas/tests/io/test_fsspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_fsspec.py b/pandas/tests/io/test_fsspec.py index a452d9136eed7..18dbd51048b67 100644 --- a/pandas/tests/io/test_fsspec.py +++ b/pandas/tests/io/test_fsspec.py @@ -271,7 +271,7 @@ def test_s3_parquet(s3_bucket_public, s3so, df1): @td.skip_if_installed("fsspec") def test_not_present_exception(): - msg = "`Import fsspec` failed. Use pip or conda to install the fsspec package." + msg = "`Import fsspec` failed. Use pip, conda or your preferred package manager to install the fsspec package." with pytest.raises(ImportError, match=msg): read_csv("memory://test/test.csv") From 70461543db41b7982b7c9bdf5b5570d789b1ab65 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Wed, 22 Oct 2025 20:23:44 +0200 Subject: [PATCH 3/7] Add missing comma --- pandas/tests/io/test_fsspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_fsspec.py b/pandas/tests/io/test_fsspec.py index 18dbd51048b67..7af9a4cb42067 100644 --- a/pandas/tests/io/test_fsspec.py +++ b/pandas/tests/io/test_fsspec.py @@ -271,7 +271,7 @@ def test_s3_parquet(s3_bucket_public, s3so, df1): @td.skip_if_installed("fsspec") def test_not_present_exception(): - msg = "`Import fsspec` failed. Use pip, conda or your preferred package manager to install the fsspec package." + msg = "`Import fsspec` failed. Use pip, conda, or your preferred package manager to install the fsspec package." with pytest.raises(ImportError, match=msg): read_csv("memory://test/test.csv") From d9c8b9958d3176338cf6cc479beffb927b22fda4 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Wed, 22 Oct 2025 20:25:14 +0200 Subject: [PATCH 4/7] Update error message in test --- pandas/tests/io/test_parquet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 2927b24624026..efc4548ede5c7 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -335,7 +335,7 @@ def test_get_engine_auto_error_message(): with pytest.raises(ImportError, match=match): get_engine("auto") else: - match = "Use pip or conda to install the fastparquet package" + match = "Use pip, conda, or your preferred package manager to install the fastparquet package" with pytest.raises(ImportError, match=match): get_engine("auto") From c88e8eaa8e5ae5501d02dbae30cc83f83d82b026 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Mon, 27 Oct 2025 22:58:15 +0100 Subject: [PATCH 5/7] Generic error message Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/compat/_optional.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index 0bc31a9a88418..0f5242659fb40 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -152,8 +152,7 @@ def import_optional_dependency( msg = ( f"`Import {install_name}` failed. {extra} " - f"Use pip, conda, or your preferred package " - f"manager to install the {install_name} package." + f"Please install the {install_name} package." ) try: module = importlib.import_module(name) From 9d9c9ad018864e8ebf368a47b46762fe45f4b7bc Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Mon, 27 Oct 2025 22:59:30 +0100 Subject: [PATCH 6/7] Simplify error message --- pandas/tests/io/test_fsspec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_fsspec.py b/pandas/tests/io/test_fsspec.py index 7af9a4cb42067..fab82c00f96fd 100644 --- a/pandas/tests/io/test_fsspec.py +++ b/pandas/tests/io/test_fsspec.py @@ -271,7 +271,7 @@ def test_s3_parquet(s3_bucket_public, s3so, df1): @td.skip_if_installed("fsspec") def test_not_present_exception(): - msg = "`Import fsspec` failed. Use pip, conda, or your preferred package manager to install the fsspec package." + msg = "`Import fsspec` failed. Please install the fsspec package." with pytest.raises(ImportError, match=msg): read_csv("memory://test/test.csv") From f51dd9f4f7da0771a8f0a01e22ba51a122dd7ad8 Mon Sep 17 00:00:00 2001 From: Matt Hall Date: Mon, 27 Oct 2025 23:00:37 +0100 Subject: [PATCH 7/7] Simplify error message --- pandas/tests/io/test_parquet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index efc4548ede5c7..1a8aba6a07632 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -335,7 +335,7 @@ def test_get_engine_auto_error_message(): with pytest.raises(ImportError, match=match): get_engine("auto") else: - match = "Use pip, conda, or your preferred package manager to install the fastparquet package" + match = "Please install the fastparquet package" with pytest.raises(ImportError, match=match): get_engine("auto")