Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with loading the "en" model #3113

Closed
PrashantSaikia opened this issue Jan 3, 2019 · 5 comments
Closed

Issue with loading the "en" model #3113

PrashantSaikia opened this issue Jan 3, 2019 · 5 comments
Labels
install Installation issues windows Issues related to Windows

Comments

@PrashantSaikia
Copy link

PrashantSaikia commented Jan 3, 2019

My environment is:

Windows 10
Python 3.5.4
spaCy 2.0.18

I downloaded and installed the en model of Spacy, like so:

    C:\Users\h473>python -m spacy download en
    Collecting en_core_web_sm==2.0.0 from https:/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm==2.0.0
      Downloading https:/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz (37.4MB)
        100% |████████████████████████████████| 37.4MB 129kB/s
    Installing collected packages: en-core-web-sm
      Running setup.py install for en-core-web-sm ... done
    Successfully installed en-core-web-sm-2.0.0
    You do not have sufficient privilege to perform this operation.
    
        Linking successful
        C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\site-packages\en_core_web_sm
        -->
        C:\Users\h473\AppData\Local\Programs\Python\Python35\lib\site-packages\spacy\data\en
    
        You can now load the model via spacy.load('en')

and it shows up when I do pip list as en-core-web-sm 2.0.0

But when I try to load it, it gives the following error:

  model = spacy.load('en')
   ---------------------------------------------------------------------------
   OSError                                   Traceback (most recent call last)
   <ipython-input-85-9186aba347c8> in <module>()
   ----> 1 model = spacy.load('en')
   
   c:\users\h473\appdata\local\programs\python\python35\lib\site-packages\spacy\__init__.py in load(name, **overrides)
        19     if depr_path not in (True, False, None):
        20         deprecation_warning(Warnings.W001.format(path=depr_path))
   ---> 21     return util.load_model(name, **overrides)
        22 
        23 
   
   c:\users\h473\appdata\local\programs\python\python35\lib\site-packages\spacy\util.py in load_model(name, **overrides)
       117     elif hasattr(name, 'exists'):  # Path or Path-like to model data
       118         return load_model_from_path(name, **overrides)
   --> 119     raise IOError(Errors.E050.format(name=name))
       120 
       121 
   
   OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

So, how do I fix this?

@brianayoung
Copy link

I'm getting the same error message, and installed en using the same method. Running Python 3.6 on a Mac.

@rbhambriiit
Copy link

"You do not have sufficient privilege to perform this operation. "

This message seems to be the issue.
Most likely the link did not create due to permission issues.

Either you should try reworking in a virtual environment where you have all permissions.

Or really try the full path instead of link.

spacy.load('en_core_web_sm')

@PrashantSaikia
Copy link
Author

PrashantSaikia commented Jan 4, 2019

"You do not have sufficient privilege to perform this operation. "

This message seems to be the issue.
Most likely the link did not create due to permission issues.

Either you should try reworking in a virtual environment where you have all permissions.

Or really try the full path instead of link.

spacy.load('en_core_web_sm')

Well, I was able to fix the errors by doing a slew of things:

  1. Copy the folder Python35\lib\site-packages\en_core_web_sm, create a folder named en in Python35\Lib\site-packages\spacy\data, paste the copied contents to en, and rename the folder as en_core_web_sm-2.0.0.

  2. Copy the __init__.py file in en_core_web_sm and paste it in en (that is, the __init__.py file must be in both Python35\Lib\site-packages\spacy\data\en and Python35\Lib\site-packages\spacy\data\en\en_core_web_sm-2.0.0

And because I actually wanted to use a package called pytextrank that uses spaCy as a dependency, I had to do the following as well to get to it work:

  1. Go to Python35\Lib\site-packages\pytextrank, and edit the file pytextrank.py as follows:
  • Add # -*- coding: utf-8 -*- at the beginning of the file.
  • Replace the line graph.edge[pair[0]][pair[1]]["weight"] += 1.0 with graph.edges[0,1]["weight"] += 1.0.
  • Replace the line doc = spacy_nlp(text.strip(), parse=True) with doc = spacy_nlp(text.strip()).
  • Replace the line doc = spacy_nlp(graf_text, parse=True) with doc = spacy_nlp(graf_text).

@PrashantSaikia PrashantSaikia reopened this Jan 4, 2019
@honnibal honnibal added install Installation issues windows Issues related to Windows labels Jan 5, 2019
@honnibal honnibal closed this as completed Jan 5, 2019
@ines
Copy link
Member

ines commented Jan 5, 2019

Thank for updating with your solution. In order to let you use the en_core_web_sm model via the shortcut link 'en', spaCy creates a symlink. This means you need to have permissions to do this. See here for more details: https://spacy.io/usage/models#usage-link

A note in case others come across this issue later: Copy-pasting the folder and renaming it is really only the last resort if you can't run the command with admin permissions and you need to be able to load the model via spacy.load('en'). This is usually not the case – you can just install the model and load it via its full name, spacy.load('en_core_web_sm'). In fact, I often prefer this syntax, since it's more explicit and you immediately know which model is loaded.

@lock
Copy link

lock bot commented Feb 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install Installation issues windows Issues related to Windows
Projects
None yet
Development

No branches or pull requests

5 participants