Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nlp=spacy.load('en_core_web_sm') KeyError: 'PUNCTSIDE_FIN' #4945

Closed
ninulik82 opened this issue Jan 27, 2020 · 6 comments
Closed

nlp=spacy.load('en_core_web_sm') KeyError: 'PUNCTSIDE_FIN' #4945

ninulik82 opened this issue Jan 27, 2020 · 6 comments

Comments

@ninulik82
Copy link

@ninulik82 ninulik82 commented Jan 27, 2020

Can someone please help?
I installed spacy 2.2.3 using conda install -c conda-forge/label/gcc7 spacy and the en model 2.2.5 using conda install -c conda-forge spacy-model-en_core_web_sm on anaconda3. Installation was successful and the kernel was restarted.

However, when I can import spacy - nlp=spacy.load('en_core_web_sm'), get the following KeyError: 'PUNCTSIDE_FIN'.
I read all the blogs on this topic but could not find any fix for my issue.

operating system - macOS
python 3.7
anaconda3 (anaconda navigator 1..9.7)
spacy 2.2.3
spacy model 2.2.5

@ninulik82

This comment has been minimized.

Copy link
Author

@ninulik82 ninulik82 commented Jan 27, 2020

Here is the full traceback info

KeyError Traceback (most recent call last)
in
----> 1 nlp=spacy.load('en_core_web_sm')

/opt/anaconda3/lib/python3.7/site-packages/spacy/init.py in load(name, **overrides)
25 if depr_path not in (True, False, None):
26 deprecation_warning(Warnings.W001.format(path=depr_path))
---> 27 return util.load_model(name, **overrides)
28
29

/opt/anaconda3/lib/python3.7/site-packages/spacy/util.py in load_model(name, **overrides)
132 return load_model_from_link(name, **overrides)
133 if is_package(name): # installed as package
--> 134 return load_model_from_package(name, **overrides)
135 if Path(name).exists(): # path to model data directory
136 return load_model_from_path(Path(name), **overrides)

/opt/anaconda3/lib/python3.7/site-packages/spacy/util.py in load_model_from_package(name, **overrides)
153 """Load a model from an installed package."""
154 cls = importlib.import_module(name)
--> 155 return cls.load(**overrides)
156
157

/opt/anaconda3/lib/python3.7/site-packages/en_core_web_sm/init.py in load(**overrides)
10
11 def load(**overrides):
---> 12 return load_model_from_init_py(file, **overrides)

/opt/anaconda3/lib/python3.7/site-packages/spacy/util.py in load_model_from_init_py(init_file, **overrides)
194 if not model_path.exists():
195 raise IOError(Errors.E052.format(path=path2str(data_path)))
--> 196 return load_model_from_path(data_path, meta, **overrides)
197
198

/opt/anaconda3/lib/python3.7/site-packages/spacy/util.py in load_model_from_path(model_path, meta, **overrides)
177 component = nlp.create_pipe(name, config=config)
178 nlp.add_pipe(component, name=name)
--> 179 return nlp.from_disk(model_path)
180
181

/opt/anaconda3/lib/python3.7/site-packages/spacy/language.py in from_disk(self, path, exclude, disable)
834 # Convert to list here in case exclude is (default) tuple
835 exclude = list(exclude) + ["vocab"]
--> 836 util.from_disk(path, deserializers, exclude)
837 self._path = path
838 return self

/opt/anaconda3/lib/python3.7/site-packages/spacy/util.py in from_disk(path, readers, exclude)
634 # Split to support file names like meta.json
635 if key.split(".")[0] not in exclude:
--> 636 reader(path / key)
637 return path
638

/opt/anaconda3/lib/python3.7/site-packages/spacy/language.py in (p, proc)
829 continue
830 deserializers[name] = lambda p, proc=proc: proc.from_disk(
--> 831 p, exclude=["vocab"]
832 )
833 if not (path / "vocab").exists() and "vocab" not in exclude:

pipes.pyx in spacy.pipeline.pipes.Tagger.from_disk()

/opt/anaconda3/lib/python3.7/site-packages/spacy/util.py in from_disk(path, readers, exclude)
634 # Split to support file names like meta.json
635 if key.split(".")[0] not in exclude:
--> 636 reader(path / key)
637 return path
638

pipes.pyx in spacy.pipeline.pipes.Tagger.from_disk.load_tag_map()

morphology.pyx in spacy.morphology.Morphology.init()

attrs.pyx in spacy.attrs.intify_attrs()

KeyError: 'PUNCTSIDE_FIN'

@adrianeboyd

This comment has been minimized.

Copy link
Collaborator

@adrianeboyd adrianeboyd commented Jan 28, 2020

Hi, this looks similar to #4372. I suspect your conda install command for spacy didn't install the most recent version. Can you run python -m spacy info to check the spacy version and also python -m spacy validate to check whether the model version is compatible with the spacy version?

I'd suggest trying just conda install -c conda-forge spacy, possibly with spacy==2.2.3 to be sure, to see if updating to the most recent version fixes the problem.

@ninulik82

This comment has been minimized.

Copy link
Author

@ninulik82 ninulik82 commented Jan 28, 2020

Hello,
Thank you for your comments. Actually, python -m spacy info and any other command with python -m produce syntax error (SyntaxError: invalid syntax) in my anaconda environment.
1)Can you suggest another command or would you know how to fix that error?

conda install -c conda-forge spacy runs and shown that " All requested packages already installed."

I checked the installation folder, and the spacy version installed is 2.1.8.
Any attempt to install 2.2.3 fail with the error
"PackagesNotFoundError: The following packages are not available from current channels: - 2.2.3"

I tried also conda "install -c conda-forge spacy==2.2.3" and got a different type of error shown below:

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: /
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
Examining conflict for py-lief cython snowballstemmer werkzeug pexpect anaconda-project xz mpmath seaborn decorator cycler wheel idna sphinxcontrib tblib singledispatch py sphinxcontrib-websupport cython-blis qtpy chardet r-data.table scipy mock fontconfig pytest-arraydiff jupyterlab_server libarchive spacy h5py olefile pyodbc conda pluggy soupsieve future cymem cffi pytest-openfiles prompt_toolkit msgpack-python cytoolz gmpy2 backports.shutil_get_terminal_size xlwings preshed colorama harfbuzz scikit-image jupyter_core distributed r-lattice mistune pickleshare ipywidgets imagesize appscript tornado contextlib2 dask-core html5lib bkcharts clyent nbconvert python parso plac jupyter_client ipykernel kiwisolver statsmodels lxml pywavelets terminado pylint thinc jdcal heapdict pyzmq ptyprocess jsonschema mkl-service cryptography rope ply six networkx zipp blosc numpydoc filelock r-reticulate sphinx pytest-doctestplus path.py jupyterlab pyopenssl pycrypto locket conda-build astroid conda-package-handling joblib srsly jupyter_console sphinxcontrib-htmlhelp backports.weakref backports.os sphinxcontrib-jsmath sphinxcontrib-devhelp jupyter pathlib2 wrapt testpath itsdangerous toolz fsspec glib webencodings pandas dask astropy pyqt bleach widgetsnbextension xlwt pycurl nltk libtiff anaconda-client anaconda nbformat wasabi sip pytest-remotedata conda-verify ninja openpyxl r-jsonlite ipython_genutils python-dateutil sympy zstd traitlets mkl_random isort pytables libxslt nose importlib_metadata click flask pycosat pytest zict babel pkginfo jedi xlrd sortedcontainers cairo pycparser fastcache r-base pytz pip murmurhash boto pytorch numexpr unicodecsv mkl_fft numpy torchvision backports certifi appnope pango ipython pep8 backports.tempfile qtconsole bokeh wurlitzer alabaster beautifulsoup4 jinja2 prometheus_client python.app r-matrix multipledispatch pyrsistent markupsafe pycodestyle json5 sphinxcontrib-serializinghtml keyring numpy-base navigator-updater bitarray spacy-model-en_core_web_sm r-rcpp matplotlib attrs numba pytest-astropy docutils wcwidth xlsxwriter python-libarchive-c simplegeneric et_xmlfile gevent qtawesome pyparsing defusedxml libxml2 backports.functools_lru_cache spacy-model-en_core_web_md partd psutil imageio setuptools mccabe bottleneck glob2 pyyaml patsy cloudpickle spyder backcall asn1crypto pillow sphinxcontrib-applehelp anaconda-navigator pygments tqdm requests more-itertools pandocfilters packaging urllib3 scikit-learn _ipyw_jlab_nb_ext_conf sqlalchemy ruamel_yaml entrypoints pysocks pyflakes llvmlite notebook r-spacyr conda-env atomicwrites sortedcollections greenlet spyder-kernels sphinxcontrib-qthelp lazy-object-proxy send2trash: 1%| | 4/329 [02:13<3:14:52, 35.98s/i|

  1. Is there another way to install the latest version of spacy or it seems to be incompatible with something else installed? If that is the case, is there a way of solving spacy english model error ?
@ninulik82

This comment has been minimized.

Copy link
Author

@ninulik82 ninulik82 commented Jan 28, 2020

I attached the full conflict info file if anyone is interested to look into it. It is big...

conda spacy conflict.ipynb.zip

@adrianeboyd

This comment has been minimized.

Copy link
Collaborator

@adrianeboyd adrianeboyd commented Jan 29, 2020

Hmm, I'm not sure what the conflict is at this point. As a first step, I'd recommend starting with a new conda environment to see if you can install spacy and a model by itself. Can you see if that works?

@no-response

This comment has been minimized.

Copy link

@no-response no-response bot commented Feb 14, 2020

This issue has been automatically closed because there has been no response to a request for more information from the original author. With only the information that is currently in the issue, there's not enough information to take action. If you're the original author, feel free to reopen the issue if you have or find the answers needed to investigate further.

@no-response no-response bot closed this Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.