diff --git a/spacy/cli/download.py b/spacy/cli/download.py index de731b0fd..35afef609 100644 --- a/spacy/cli/download.py +++ b/spacy/cli/download.py @@ -7,7 +7,13 @@ from wasabi import msg from .. import about from ..errors import OLD_MODEL_SHORTCUTS -from ..util import get_minor_version, is_package, is_prerelease_version, run_command +from ..util import ( + get_minor_version, + is_in_jupyter, + is_package, + is_prerelease_version, + run_command, +) from ._util import SDIST_SUFFIX, WHEEL_SUFFIX, Arg, Opt, app @@ -78,6 +84,22 @@ def download( f"You can now load the package via spacy.load('{model_name}')", ) + reload_deps_msg = ( + "If you have one or more instances of the Python runtime executing " + "in the background, you'll need to restart them to correctly load " + "the dependencies of the newly downloaded model. " + ) + if is_in_jupyter(): + reload_deps_msg = ( + f"{reload_deps_msg}This includes the current Jupyter session: " + "You can do this clicking on the 'Restart Kernel' button (or " + "'Restart Runtime' button in the case of Google Colab)" + ) + msg.info( + "Reloading dependencies", + reload_deps_msg, + ) + def get_model_filename(model_name: str, version: str, sdist: bool = False) -> str: dl_tpl = "{m}-{v}/{m}-{v}{s}" diff --git a/spacy/errors.py b/spacy/errors.py index 29694532f..db1a886aa 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -229,10 +229,8 @@ class Errors(metaclass=ErrorsWithCodes): "If you're using a Transformer, make sure to install 'spacy-transformers'. " "If you're using a custom component, make sure you've added the " "decorator `@Language.component` (for function components) or " - "`@Language.factory` (for class components). If you installed the model " - "during the current Python/Jupyter session, you'll need to restart Python (or " - "reload your Jupyter notebook) to correctly load the dependencies.\n\n" - "Available factories: {opts}") + "`@Language.factory` (for class components).\n\nAvailable " + "factories: {opts}") E003 = ("Not a valid pipeline component. Expected callable, but " "got {component} (name: '{name}'). If you're using a custom " "component factory, double-check that it correctly returns your "