简体   繁体   中英

I tried everything but couldn't import SpaCy

I'm trying to build a project with SpaCy as a linguist however I'm not good at programming stuff. I tried everything I know but couldn't import spacy. I used pip, I added libraries on settings of Pycharm, I tried everything. How can I solve it?

I would recommend that you read this spacy quickstart for some instructions on Spacy installation and first steps.

In general, the following recipe should work for you:

  1. Install Spacy on your env for example using pip :
pip install spacy
  1. Install the spacy models you will need. For example installing en_core_web_sm for basic NLP tasks in English language:
python -m spacy download en_core_web_sm
  1. Load model from a Python script and make a few tests:
import spacy

nlp = spacy.load("en_core_web_sm")  # Load model
doc = nlp("This is a sentence.")    # Build a doc from a simple string

# Print tokens in doc
for token in doc:
    print(token.text, token.pos_, token.dep_)

In case this is your first time working with Spacy, spaCy-101 is an amazing official tutorial that will gradually introduce you to the basic concepts of NLP and how they are implemented in Spacy.

I hope this helps you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM