openeventdata / mordecai

Full text geoparsing as a Python library
MIT License
742 stars 97 forks source link

"'nlp' is not defined" #64

Closed organizejs closed 5 years ago

organizejs commented 5 years ago

I'm getting an issue when running a simple test script

from mordecai import Geoparser
geo = Geoparser()
geo.geoparse("From Ottowa to Beijing.")

This is the error: image

ahalterman commented 5 years ago

Which version of spaCy are you running? I just tried with 2.0.16 and it worked.

organizejs commented 5 years ago

@ahalterman i'm using spaCy version: 2.0.18 Let me downgrade and try again

organizejs commented 5 years ago

i downgraded and i'm getting the exact same issue

ahalterman commented 5 years ago

Huh. Thanks for checking. What happens if you explicitly create the nlp object before calling Mordecai?

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

# then load mordecai
from mordecai import Geoparser
geo = Geoparser()
geo.geoparse("From Ottowa to Beijing.")
organizejs commented 5 years ago

i get the same issue: image

organizejs commented 5 years ago

any chance it might be numpy version related?

ahalterman commented 5 years ago

It looks like an issue with your spaCy installation. This issue seems to be the same and was solved by a fresh install.

You could also take a look at spacy's validate command, which checks whether the models are compatible with your current version: https://spacy.io/api/cli#validate

organizejs commented 5 years ago

Thanks i'll try out a fresh install and keep you posted.

organizejs commented 5 years ago

Looks like re-creating the virtual env worked. Thanks

ahalterman commented 5 years ago

Happy to help!

wangjiqing1 commented 2 years ago

@organizejs 您好,请问你成功运行的环境spacy版本号是多少?还有这个en_core_web_lg