From 3463ded7cf37868130284054eea82e16702d095a Mon Sep 17 00:00:00 2001 From: ines Date: Tue, 3 Apr 2018 22:18:47 +0200 Subject: [PATCH] Check if spaCy has compiled correctly and show error message --- spacy/__init__.py | 9 ++++++++- spacy/errors.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/spacy/__init__.py b/spacy/__init__.py index bda109086..e54aa244b 100644 --- a/spacy/__init__.py +++ b/spacy/__init__.py @@ -1,10 +1,17 @@ # coding: utf8 from __future__ import unicode_literals +from .errors import Errors, Warnings, deprecation_warning + +try: + # check if spaCy has compiled correctly (if it hasn't this will raise) + import spacy.symbols +except ModuleNotFoundError: + raise ImportError(Errors.E094) + from .cli.info import info as cli_info from .glossary import explain from .about import __version__ -from .errors import Warnings, deprecation_warning from . import util diff --git a/spacy/errors.py b/spacy/errors.py index 2713f76c8..22a8dd5b3 100644 --- a/spacy/errors.py +++ b/spacy/errors.py @@ -244,6 +244,10 @@ class Errors(object): "Alternatively, it is built from the 'lang' and 'name' keys in " "the meta.json. Vector names are required to avoid issue #1660.") E093 = ("token.ent_iob values make invalid sequence: I without B\n{seq}") + E094 = ("Can't import from compiled modules. This usually indicates that " + "spaCy hasn't compiled correcty. If you're on Windows, make sure " + "you have a compiler, i.e. the Visual C++ Build Tools installed. " + "See the installation docs for more info: https://spacy.io/usage/") @add_codes