Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

python - Spacy cannot find model

There are tickets or bugs across the internet on this and because there's Spacy 2.3 and 3.0 I can't tell which is relevant. I'm running 2.3 because moving to 3.0 is like moving to dojo 2.0. All that youtube watching is down the drain. Anyway, the following works:

spacy.load(r'C:Usersmartingale.henriettaAppDataLocalContinuumanaconda3envsspacyLibsite-packagesen_core_web_smen_core_web_sm-2.3.1')

or

nlp = en_core_web_sm.load()

But the line that's in every tutorial is -

spacy.load('en_core_web_sm')

or even

spacy.load('en')

if you're really courageous, never works for me. My path includes:

['',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\python36.zip',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\DLLs',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\lib',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\lib\site-packages',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\lib\site-packages\win32',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\lib\site-packages\win32\lib',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\lib\site-packages\Pythonwin',
 'C:\Users\martingale.henrietta\AppData\Local\Continuum\anaconda3\envs\spacy\lib\site-packages\IPython\extensions',
 'C:\Users\martingale.henrietta\.ipython',
 'C:\Users\martingale.henrietta\OneDrive - 247 Customer Pvt. Ltd\workspace\247',
 'C:\Users\martingale.henrietta\OneDrive - 247 Customer Pvt. Ltd\workspace\247']

And, of course, this is in a Jupyter notebook. How do I get spacy to do spacy.load('en') in 2.3?

question from:https://stackoverflow.com/questions/66048470/spacy-cannot-find-model

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

How do I get spacy to do spacy.load('en') in 2.3?

You can't. From the docs:

Note that as of spaCy v3.0, shortcut links like en that create (potentially brittle) symlinks in your spaCy installation are deprecated. To download and load an installed pipeline package, use its full name:

The shortcuts were based on symlinks, and they always had issues with Windows, or with installing multiple models for the same language, and other things, so they took them out. Except for the argument being longer there's no difference.

This should work just fine:

spacy.load('en_core_web_sm')

If it doesn't work, make sure you actually downloaded the model and post your error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...