Check if spaCy has compiled correctly and show error message

This commit is contained in:
ines 2018-04-03 22:18:47 +02:00
parent e5f47cd82d
commit 3463ded7cf
2 changed files with 12 additions and 1 deletions

View File

@ -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

View File

@ -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