question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoneType uncallable on spacy.load('fr') (if self.is_base_form(univ_pos, morphology))

See original GitHub issue

How to reproduce the behaviour

I am trying to get lemmatization/stemming to work with spaCy and spaCy_lefff in French. However, everytime I try to execute this code block in iPython kernel (jupyter notebook):

import spacy
nlp = spacy.load("fr")

doc = nlp("C'est une phrase.")
print([(w.text, w.pos_) for w in doc])

I am getting the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
 in 
      2 nlp = spacy.load("fr_core_news_sm")
      3 
----> 4 doc = nlp("C'est une phrase.")
      5 print([(w.text, w.pos_) for w in doc])

~/anaconda3/lib/python3.7/site-packages/spacy/language.py in __call__(self, text, disable, component_cfg)
    447             if not hasattr(proc, "__call__"):
    448                 raise ValueError(Errors.E003.format(component=type(proc), name=name))
--> 449             doc = proc(doc, **component_cfg.get(name, {}))
    450             if doc is None:
    451                 raise ValueError(Errors.E005.format(name=name))

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

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

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

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

~/anaconda3/lib/python3.7/site-packages/spacy/lang/fr/lemmatizer.py in __call__(self, string, univ_pos, morphology)
     47             return [self.lookup(string)]
     48         # See Issue #435 for example of where this logic is requied.
---> 49         if self.is_base_form(univ_pos, morphology):
     50             return list(set([string.lower()]))
     51         index_table = self.lookups.get_table("lemma_index", {})

TypeError: 'NoneType' object is not callable

I have downloaded with python -m spacy download fr and python -m spacy download fr_core_news_sm.

Your Environment

Info about spaCy

  • spaCy version: 2.3.1

  • Platform: Linux-5.3.0-62-generic-x86_64-with-debian-buster-sid

  • Python version: 3.7.6

  • Models: fr, en

  • Environment Information: iPython kernel, Jupyter Notebook, Anaconda3

Extra

I have downloaded with python -m spacy download fr and python -m spacy download fr_core_news_sm. Extra info:

❯ python -m spacy validate
✔ Loaded compatibility table

====================== Installed models (spaCy v2.3.1) ======================
ℹ spaCy installation:
/home/bart/anaconda3/lib/python3.7/site-packages/spacy

TYPE      NAME              MODEL             VERSION                            
package   fr-core-news-sm   fr_core_news_sm   2.3.0   ✔
package   en-core-web-sm    en_core_web_sm    2.3.1   ✔
link      fr                fr_core_news_sm   2.3.0   ✔
link      en                en_core_web_sm    2.3.1   ✔

❯ python -m spacy info

============================== Info about spaCy ==============================

spaCy version    2.3.1                         
Location         /home/bart/anaconda3/lib/python3.7/site-packages/spacy
Platform         Linux-5.3.0-62-generic-x86_64-with-debian-buster-sid
Python version   3.7.6                         
Models           fr, en

The english package does work however:

import spacy
nlp = spacy.load("en")

doc = nlp("Just a phrase.")
print([(w.text, w.pos_) for w in doc])

with output

[('Just', 'ADV'), ('a', 'DET'), ('phrase', 'NOUN'), ('.', 'PUNCT')]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
adrianeboydcommented, Jul 8, 2020

The bug is in spacy v2.3.1. If you downgrade to v2.3.0 it should work. The models haven’t changed (and won’t need to change, the bug is in spacy itself).

1reaction
adrianeboydcommented, Jul 9, 2020

The problem is not the model version, it is the spacy version. Try downgrading to spacy==2.3.0 temporarily. We will have a fix in a new version of spacy soon, which should be 2.3.2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spacy French langage gives NoneType error - python
This seems to be a bug at spaCy 2.3.1: https://github.com/explosion/spaCy/issues/5728. Downgrade to 2.3.0 and it should work: pip install ...
Read more >
French · spaCy Models Documentation
spaCy is a free open-source library for Natural Language Processing in Python. It features NER, POS tagging, dependency parsing, word vectors and more....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found