diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index f01dfab0de829..07a07ba4ab60c 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -152,8 +152,8 @@ def import_optional_dependency( install_name = package_name if package_name is not None else name msg = ( - f"Missing optional dependency '{install_name}'. {extra} " - f"Use pip or conda to install {install_name}." + f"`Import {install_name}` failed. {extra} " + f"Use pip or conda to install the {install_name} package." ) try: module = importlib.import_module(name) diff --git a/pandas/tests/io/test_fsspec.py b/pandas/tests/io/test_fsspec.py index 2e3e74a9d31ff..8fb790b24b621 100644 --- a/pandas/tests/io/test_fsspec.py +++ b/pandas/tests/io/test_fsspec.py @@ -282,7 +282,7 @@ def test_s3_parquet(s3_public_bucket, s3so, df1): @td.skip_if_installed("fsspec") def test_not_present_exception(): - msg = "Missing optional dependency 'fsspec'|fsspec library is required" + msg = "`Import fsspec` failed. Use pip or conda to install the fsspec package." with pytest.raises(ImportError, match=msg): read_csv("memory://test/test.csv") diff --git a/pandas/tests/io/test_parquet.py b/pandas/tests/io/test_parquet.py index 78f39b649cb9a..52f8d6b2f06d8 100644 --- a/pandas/tests/io/test_parquet.py +++ b/pandas/tests/io/test_parquet.py @@ -325,7 +325,7 @@ def test_get_engine_auto_error_message(): with pytest.raises(ImportError, match=match): get_engine("auto") else: - match = "Missing optional dependency .pyarrow." + match = "Import .pyarrow failed." with pytest.raises(ImportError, match=match): get_engine("auto") diff --git a/pandas/tests/test_optional_dependency.py b/pandas/tests/test_optional_dependency.py index 9127981d1845d..cd276914bfb21 100644 --- a/pandas/tests/test_optional_dependency.py +++ b/pandas/tests/test_optional_dependency.py @@ -12,7 +12,7 @@ def test_import_optional(): - match = "Missing .*notapackage.* pip .* conda .* notapackage" + match = "Import .*notapackage.* pip .* conda .* notapackage" with pytest.raises(ImportError, match=match) as exc_info: import_optional_dependency("notapackage") # The original exception should be there as context: diff --git a/pandas/tests/util/test_numba.py b/pandas/tests/util/test_numba.py index 27b68ff0f6044..b555240b3b657 100644 --- a/pandas/tests/util/test_numba.py +++ b/pandas/tests/util/test_numba.py @@ -7,6 +7,6 @@ @td.skip_if_installed("numba") def test_numba_not_installed_option_context(): - with pytest.raises(ImportError, match="Missing optional"): + with pytest.raises(ImportError, match="Import numba failed"): with option_context("compute.use_numba", True): pass