Skip to content

Remove change of ImportError message for optional dependencies #2104

Description

@paskino

Description

With #2093 requirements, such as matplotlib, have been made optional. This means that not having matplotlib should not stop users installing and using CIL, unless they explicitly try to use functionality that depends on it.

In the above PR, code like below has been added, with the attempt to give the user some guidance on how to install such dependency.

try:
import matplotlib.pyplot as plt
except ImportError as exc:
msg = "matplotlib-base (e.g. `conda install conda-forge::matplotlib-base`)"
raise ImportError(f"Please install {msg}") from exc

This is not necessary. An ImportError error message should be sufficient to explain where the problem is. We could maintain, and we do, a list of optional prerequisites and instructions on how to install them.

The suggestion is therefore, to revert the adding of the try/except that changes the ImportError message introduced in #2093

Environment

import cil, sys
print(cil.version.version, cil.version.commit_hash, sys.version, sys.platform)

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions