diff --git a/spacy/errors.py b/spacy/errors.py index f8a461dbd..fc98fdaa6 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -487,6 +487,9 @@ class Errors: # New errors added in v3.x + E880 = ("The 'wandb' library could not be found - did you install it? " + "Alternatively, specify the 'ConsoleLogger' in the 'training.logger' " + "config section, instead of the 'WandbLogger'.") E885 = ("entity_linker.set_kb received an invalid 'kb_loader' argument: expected " "a callable function, but got: {arg_type}") E886 = ("Can't replace {name} -> {tok2vec} listeners: path '{path}' not " diff --git a/spacy/training/loggers.py b/spacy/training/loggers.py index 79459a89b..8acf2783c 100644 --- a/spacy/training/loggers.py +++ b/spacy/training/loggers.py @@ -103,7 +103,11 @@ def console_logger(progress_bar: bool = False): @registry.loggers("spacy.WandbLogger.v1") def wandb_logger(project_name: str, remove_config_values: List[str] = []): - import wandb + try: + import wandb + from wandb import init, log, join # test that these are available + except ImportError: + raise ImportError(Errors.E880) console = console_logger(progress_bar=False)