0

I am attempting to install spacy and have tried a number of methods using pip, conda, and installing directing from git. However, I am running into the same error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[26], line 3
      1 import spacy
----> 3 nlp = spacy.load("en_core_web_sm")

AttributeError: module 'spacy' has no attribute 'load'

From reading various articles online like this one, I see that my error is likely due to a file called "spacy.py" that is causing a shadowing error. However, I can't find this file. I feel like this is likely an easy thing to find but have yet to find it :(

Using which python in my dir shows me:

/Users/my_name/anaconda3/bin/python

Looking into my anaconda3/bin/python dir, I do see a Unix Executable file named "spacy" but renaming it has not fixed my error.

psychcoder
  • 543
  • 3
  • 14
  • Does this answer your question? [How to retrieve a module's path?](https://stackoverflow.com/questions/247770/how-to-retrieve-a-modules-path) – Nick ODell Aug 10 '23 at 17:45
  • 2
    You can do this with something like `import spacy; print(spacy.__file__)`. That will give you the path Python is loading the module from. – Nick ODell Aug 10 '23 at 17:46

1 Answers1

1

Make sure you're also installing your preferred package:

For pip:

python -m spacy download en_core_web_sm

Also, if you're using a virtual environment in your IDE, you should also run the following commands BEFORE installing spacy and your preferred package:

For pip:

python -m venv .env
source .env/bin/activate

For conda:

conda create -n venv
conda activate venv

There could also be a mismatch between your environments. If you're using Anaconda, try installing spacy in the Anaconda Powershell. Otherwise, try installing spacy using conda and/or pip in your IDE's terminal.