@@ -243,7 +243,7 @@ def _download_additional_modules(
243243 elif import_type == "external" :
244244 url_or_filename = import_path
245245 else :
246- raise ValueError ("Wrong import_type" )
246+ raise ValueError (f "Wrong import_type: { import_type !r } . Expected 'library', 'internal', or 'external'. " )
247247
248248 local_import_path = cached_path (
249249 url_or_filename ,
@@ -255,20 +255,18 @@ def _download_additional_modules(
255255
256256 # Check library imports
257257 needs_to_be_installed = set ()
258- for library_import_name , library_import_path in library_imports :
258+ for library_import_name , _ in library_imports :
259259 try :
260- lib = importlib .import_module (library_import_name ) # noqa F841
260+ importlib .import_module (library_import_name ) # noqa F841
261261 except ImportError :
262262 library_import_name = "scikit-learn" if library_import_name == "sklearn" else library_import_name
263- library_import_path = "scikit-learn" if library_import_path == "sklearn" else library_import_path
264263 library_import_name = "absl-py" if library_import_name == "absl" else library_import_name
265- library_import_path = "absl-py" if library_import_path == "absl" else library_import_path
266- needs_to_be_installed .add ((library_import_name , library_import_path ))
264+ needs_to_be_installed .add (library_import_name )
267265 if needs_to_be_installed :
266+ missing = sorted (needs_to_be_installed )
268267 raise ImportError (
269- f"To be able to use { name } , you need to install the following dependencies"
270- f"{ [lib_name for lib_name , lib_path in needs_to_be_installed ]} using 'pip install "
271- f"{ ' ' .join ([lib_path for lib_name , lib_path in needs_to_be_installed ])} ' for instance."
268+ f"To be able to use { name } , you need to install these dependencies: "
269+ f"{ ', ' .join (missing )} using the command 'pip install { ' ' .join (missing )} '."
272270 )
273271 return local_imports
274272
0 commit comments