Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

python - Import error with spacy: "No module named en"

I'm having trouble using the Python spaCy library. It seems to be installed correctly but at

from spacy.en import English

I get the following import error:

Traceback (most recent call last):
  File "spacy.py", line 1, in <module>
    from spacy.en import English
  File "/home/user/CmdData/spacy.py", line 1, in <module>
    from spacy.en import English
ImportError: No module named en

I'm not very familiar with Python but that's the standard import I saw online, and the library is installed:

$ pip list | grep spacy
spacy (0.99)

EDIT I tested renaming the file, but that's not the problem. I also get the same error when doing:

$ python -m spacy.en.download --force all
/usr/bin/python: No module named en

(The command is supposed to download some models)

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

For windows, open cmd with admin right. Then,

python -m spacy download en 

You should see the shell prompt stating.

You can now load the model via spacy.load('en')


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...