cannot import name get_json_validator

install
spacy
solved

(Mario Scheliga) #1

I do have python 3.7.1 on ubuntu 18.04, using spacy==2.0.18 and prodigy 1.7.1 - right after installation am getting ImportError: cannot import name get_json_validator

am not sure if this might be connected before am getting an RuntimeWarning about the spacy.vocab.Vocab.

/home/marsch/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: spacy.vocab.Vocab size changed, may indicate binary incompatibility. Expected 96 from C header, got 104 from PyObject
  return f(*args, **kwds)
Traceback (most recent call last):
  File "/home/marsch/anaconda3/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/marsch/anaconda3/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/home/marsch/anaconda3/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/home/marsch/anaconda3/lib/python3.7/site-packages/prodigy/__init__.py", line 10, in <module>
    from . import recipes  # noqa
  File "/home/marsch/anaconda3/lib/python3.7/site-packages/prodigy/recipes/__init__.py", line 4, in <module>
    from . import dep, ner, textcat, pos, compare, terms, generic, image  # noqa
  File "/home/marsch/anaconda3/lib/python3.7/site-packages/prodigy/recipes/ner.py", line 18, in <module>
    from ..models.matcher import PatternMatcher
  File "cython_src/prodigy/models/matcher.pyx", line 4, in init prodigy.models.matcher
  File "/home/marsch/anaconda3/lib/python3.7/site-packages/spacy/matcher/__init__.py", line 4, in <module>
    from .matcher import Matcher  # noqa: F401
  File "matcher.pyx", line 21, in init spacy.matcher.matcher
ImportError: cannot import name get_json_validator

any ideas whats going wrong here? thank you :slight_smile:


(Ines Montani) #2

Did you previously have spacy-nightly installed or built from source in the same environment? That validator function it’s referring to was only introduced in a recent nightly

It looks like you might have installed spaCy 2.0.18 on top of the nightly, but still ended up with some leftover compiled artifacts. Unfortunately, pip doesn’t always clean existing installation properly, especially if they contain compiled source files that aren’t being overwritten (like matcher.matcher, which is a new module).

The solution is kinda unsatisfying, but I’d suggest starting with a clean, virtual environment and installing the Prodigy wheel again from scratch!


(Mario Scheliga) #3

Thanks Ines,

yeah - you are right. just forgot, so i’ve uninstall spacy nightly and some other dependencies just in case and reinstalled spacy 2.0.18

pip uninstall spacy-nightly
pip uninstall thinc
pip uninstall cymem
pip install spacy

(not sure if uninstalling thinc and cymem)

but this did the trick! :hugs::+1: