hamelsmu / Seq2Seq_Tutorial

Code For Medium Article "How To Create Data Products That Are Magical Using Sequence-to-Sequence Models"
Apache License 2.0
138 stars 50 forks source link

OSError: Can't find model 'en' #1

Closed ClaudeCoulombe closed 6 years ago

ClaudeCoulombe commented 6 years ago

I've imported the data and install keytext without problem but I've got the error below when trying to execute from ktext.preprocess import processor

It seems that the spaCy 'en' model can't be loaded. I'm using Python 3.6 on Mac OS 10.12.6

By the way, I would like to share your blog post with the G+ Deep Learning community but I have the habit to validate every tutorial myself before.

`--------------------------------------------------------------------------- OSError Traceback (most recent call last)

in () 1 get_ipython().magic('reload_ext autoreload') 2 get_ipython().magic('autoreload 2') ----> 3 from ktext.preprocess import processor /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ktext/preprocess.py in () 19 import timeit 20 ---> 21 spacyen_default = spacy.load('en') 22 23 def get_time(): /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/spacy/__init__.py in load(name, **overrides) 17 "to load. For example:\nnlp = spacy.load('{}')".format(depr_path), 18 'error') ---> 19 return util.load_model(name, **overrides) 20 21 /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/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("Can't find model '%s'" % name) 120 121 OSError: Can't find model 'en' ---------------------------------------------------------------------------`
hamelsmu commented 6 years ago

@ClaudeCoulombe try this in your terminal

python -m spacy download en

does that work?

ClaudeCoulombe commented 6 years ago

Yess, it works! Thanks for your pretty fast answer!

I've tried with pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz --no-depswith no success.

But python -m spacy download enworks well. For the moment, I'm waiting after the preprocessing which seems to be long and memory consuming. I'm better to switch to cloud... I think...

I'll close the issue.

Saravana08 commented 6 years ago

Hi, your solution (python -m spacy download en) worked perfectly, but it says download successfull but linking failed! can you please help me.

Anujay-Saraf commented 6 years ago

Hi , Its giving me the same issue, after downloading it says linking failed

Saravana08 commented 6 years ago

Hi, this got resolved when i opened the cmd prompt as an Administrator, kindly open anaconda as an admin and then run the same commands, it should work.

theSaumya commented 6 years ago

I am logged in through the Admin account, but it still getting the linking error.

hengqiali commented 5 years ago

Thanks,

@ClaudeCoulombe try this in your terminal

python -m spacy download en

does that work?

Thanks,it works for me.

WrathofBhuvan11 commented 5 years ago

Thanks,

@ClaudeCoulombe try this in your terminal

python -m spacy download en

does that work?

Thanks,it works for me.

No it says it can't link

ChenMus commented 5 years ago

Hi,it have showed linking successfully, but when I print 'nlp = spacy.load('en')' in prompt,it doesn't work ..

koliko commented 5 years ago

python -m spacy download en shows /usr/bin/python: No module named spacy

hamelsmu commented 5 years ago

@koliko are you running this code inside the provided docker container? if not, looks like you do not have spacy installed, so you will have to first install spacy

pip install spacy

venkey143228 commented 5 years ago

Good evening sir, I am beginner to spacy.. i installed spacy successfully and en module too. but when am load the en module the following error came.

import spacy nlp=spacy.load('en') txt=nlp("hello world") print(txt)

error: 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.

ClaudeCoulombe commented 5 years ago

Maybe an answer to many people.

python -m spacy download en works only if you have administration rights, the installation folder should have admin rights

LargoTerranova commented 5 years ago

For those using Anaconda I found the following solution to install the en package and link it succesully:

  1. Right clik on the Anaconda Promt Icon
  2. Go to "More" and click on "Open as Administrator"
  3. Then type: python -m spacy download en

It worked for me

venkey143228 commented 5 years ago

when i try ...it shows the following error sir... Creating a shortcut link for 'en' didn't work (maybe you don't have admin permissions?), but you can still load the model via its full package name: nlp = spacy.load('{name}') Download successful but linking failed

On Fri, Mar 8, 2019 at 11:30 PM Largo notifications@github.com wrote:

For those using Anaconda I found the following solution to install the en package and link it succesully:

  1. Right clik on the Anaconda Promt Icon
  2. Go to "More" and click on "Open as Administrator"
  3. Then type: python -m spacy download en

It worked for me

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/hamelsmu/Seq2Seq_Tutorial/issues/1#issuecomment-471019755, or mute the thread https://github.com/notifications/unsubscribe-auth/AuDQRsOsK-LefAomqSxczJ2P1zGtd8gTks5vUqVZgaJpZM4RmG5F .

-- Thanks and Regards

B Venkateswarlu, Department of Computer Science, Central University of Tamilnadu.

rtehporp commented 5 years ago

@venkey143228 Maybe you should use sudo python -m spacy download en on linux. Or you should use administrator cmd to run python -m spacy download en on windows.

julomoppet commented 5 years ago

@venkey143228 @AnujaySaraf @theSaumya same issue with me, but for some reasons when I do spacy.load('en_core_web_sm') it does work...

venkey143228 commented 5 years ago

Yes ...for me too its working

On Thu, Mar 21, 2019 at 10:03 PM Julomoppet notifications@github.com wrote:

@venkey143228 https://github.com/venkey143228 @AnujaySaraf https://github.com/AnujaySaraf @theSaumya https://github.com/theSaumya same issue with me, but for some reasons when I do spacy.load('en_core_web_sm') it does work...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hamelsmu/Seq2Seq_Tutorial/issues/1#issuecomment-475305262, or mute the thread https://github.com/notifications/unsubscribe-auth/AuDQRoD2T29Ym3bpQuePNgwOm9c8iO9fks5vY7RTgaJpZM4RmG5F .

-- Thanks and Regards

B Venkateswarlu, MSc Computer Science, Central University of Tamilnadu Thiruvarur. 610005

adhamKahlawi commented 5 years ago

I did all this Right clik on the Anaconda Promt Icon Go to "More" and click on "Open as Administrator" Then type: python -m spacy download it_core_news_sm but I have the same error OSError: [E050] Can't find model 'it_core_news_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

vicky-arumugam commented 5 years ago

Exception: Traceback (most recent call last): File "C:\python\lib\site-packages\pip_internal\cli\base_command.py", line 176, in main status = self.run(options, args) File "C:\python\lib\site-packages\pip_internal\commands\install.py", line 346, in run session=session, autobuilding=True File "C:\python\lib\site-packages\pip_internal\wheel.py", line 848, in build assert building_is_possible AssertionError

KIC commented 5 years ago

Same here.

python -m spacy download de_core_news_md
Requirement already satisfied: de_core_news_md==2.1.0 from https://github.com/explosion/spacy-models/releases/download/de_core_news_md-2.1.0/de_core_news_md-2.1.0.tar.gz#egg=de_core_news_md==2.1.0 in c:\programdata\anaconda3\lib\site-packages (2.1.0)
✔ Download and installation successful
You can now load the model via spacy.load('de_core_news_md')

but actually loading it fails with

lib\site-packages\spacy\util.py in load_model(name, **overrides)
    134     elif hasattr(name, "exists"):  # Path or Path-like to model data
    135         return load_model_from_path(name, **overrides)
--> 136     raise IOError(Errors.E050.format(name=name))
    137 
    138 

OSError: [E050] Can't find model 'de_core_news_md'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

I am using spacy 2.1.3 via coda on windows

ranjankumar-gh commented 5 years ago

Worked when I run Anaconda Prompt as an Administrator. Thanks

syafiqzolkeply commented 5 years ago

Hi,

I really need help with the installation of en model. I have successfully installed spacy using the following command:

sudo conda install -c conda-forge spacy (since everyone suggested to login as administrator)

But when I want to install the en model using the following command:

sudo python -m spacy download en

I received the following errors:

Traceback (most recent call last): File "/Users/mycomputer/anaconda3/lib/python3.6/runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/Users/mycomputer/anaconda3/lib/python3.6/runpy.py", line 142, in _get_module_details return _get_module_details(pkg_main_name, error) File "/Users/mycomputer/anaconda3/lib/python3.6/runpy.py", line 109, in _get_module_details import(pkg_name) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/spacy/init.py", line 12, in from .cli.info import info as cli_info File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/spacy/cli/init.py", line 1, in from .download import download # noqa: F401 File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/spacy/cli/download.py", line 11, in from .link import link File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/spacy/cli/link.py", line 9, in from .. import util File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/spacy/util.py", line 5, in import pkg_resources File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 3191, in @_call_aside File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 3175, in _call_aside f(*args, kwargs) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 3219, in _initialize_master_working_set for dist in working_set File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 3219, in for dist in working_set File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 2726, in activate declare_namespace(pkg) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 2252, in declare_namespace _handle_ns(packageName, path_item) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/pkg_resources/init.py", line 2185, in _handle_ns loader.load_module(packageName) File "./google.py", line 15, in model = gensim.models.keyedvectors.KeyedVectors.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/gensim/models/keyedvectors.py", line 1119, in load_word2vec_format limit=limit, datatype=datatype) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/gensim/models/utils_any2vec.py", line 173, in _load_word2vec_format with utils.smart_open(fname) as fin: File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/smart_open/smart_open_lib.py", line 181, in smart_open fobj = _shortcut_open(uri, mode, kw) File "/Users/mycomputer/anaconda3/lib/python3.6/site-packages/smart_open/smart_open_lib.py", line 301, in _shortcut_open return open(parsed_uri.uri_path, mode, buffering=buffering, **open_kwargs) FileNotFoundError: [Errno 2] No such file or directory: 'GoogleNews-vectors-negative300.bin

Can someone help me with this?

Thanks

zhangzexdu commented 5 years ago

I installed the spacy and used python3 -m spacy download en to link successfully. Linking successful /Users/kindler/anaconda3/lib/python3.6/site-packages/en_core_web_sm --> /Users/kindler/anaconda3/lib/python3.6/site-packages/spacy/data/en

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

If I use the terminal python command line it will be load normally, but use the pycharm in the same virtualenv environment it will report an error.

/Users/kindler/.virtualenvs/allennlp_latest/bin/python /Users/kindler/Documents/Projects/2019/4/preprocessing_dataset/processing/FewRel/preprocessing.py
Loading the json files ...
Traceback (most recent call last):
  File "/Users/kindler/Documents/Projects/2019/4/preprocessing_dataset/processing/FewRel/preprocessing.py", line 24, in <module>
    main()
  File "/Users/kindler/Documents/Projects/2019/4/preprocessing_dataset/processing/FewRel/preprocessing.py", line 12, in main
    dataloader = JSONDataLoader()
  File "/Users/kindler/Documents/Projects/2019/4/preprocessing_dataset/processing/FewRel/data_loader.py", line 17, in __init__
    self.nlp = spacy.load("en")
  File "/Users/kindler/.virtualenvs/allennlp_latest/lib/python3.6/site-packages/spacy/__init__.py", line 21, in load
    return util.load_model(name, **overrides)
  File "/Users/kindler/.virtualenvs/allennlp_latest/lib/python3.6/site-packages/spacy/util.py", line 119, in load_model
    raise IOError(Errors.E050.format(name=name))
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.

Can someone help me with this?

Thanks .

sean-m-higgins commented 5 years ago

Im using Python 3.6 and "python3 -m spacy download en" while in my site-packages directory worked for me!

masterchop commented 5 years ago

Thanks,

@ClaudeCoulombe try this in your terminal

python -m spacy download en

does that work?

Thanks,it works for me.

No it says it can't link

You need to do sudo python -m spacy download en

mario-marques commented 5 years ago

It worked for me too, thank you!

RyanBe123 commented 5 years ago

I tried all the methods above and it didn't work, what finally worked for me was ensuring I was installing spacy==2.0.13 (from issue #2849). Now if i spacy.load('en') it works and it links. When I start python in the anaconda prompt box, import spacy and type spacy.load('en') then run it, it works. However, when, I try and run it in my spyder console (3.3.5) using a environment running python 3.6, where Spacy is also installed, I get the same error:

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.

Anyone know why there is a discrepnacy between my IPython console on spyder and my anaconda prompt?

qmeeus commented 5 years ago

On linux this worked for me: First install the module without sudo rights with python -m spacy download nl_core_news_sm Then, to import it:

import os.path as p
import spacy

env_path = p.join(p.expanduser("~/.local/bin/anaconda3/envs/<env-name>"))
path_to_module = p.join(env_path, "lib/python3.7/site-packages/nl_core_news_sm/nl_core_news_sm-2.1.0")

nlp = spacy.load(path_to_module)

I think this can (and should) be fixed by using the name of the executable to find the module in scipy.load, something like:

import sys, os

def find_model(model_name):
    path_to_env = p.abspath(p.join(sys.executable, "../.."))
    path_to_modules = p.join(path_to_env, f"lib/python{sys.version[:3]}/site-packages")
    path_to_model = p.join(path_to_modules, model_name)
    if not p.exists(path_to_model):
        raise FileNotFoundError(path_to_model)
    model_dir = [d for d in os.listdir(path_to_model) if d.startswith(model_name)][0]
    return p.join(path_to_model, model_dir)

find_model("nl_core_news_sm")
jakaseptiadi commented 5 years ago

i have to try this "python -m spacy download en", but still doesn't work. It says "Download successful but linking failed". Anyone can help me to fix this problem?

masterchop commented 5 years ago

i have to try this "python -m spacy download en", but still doesn't work. It says "Download successful but linking failed". Anyone can help me to fix this problem?

Maybe a permission problem? also there are different way to get that, you may want to try:

python -m spacy download en_core_web_sm

ptiwari2407 commented 4 years ago

Okay, I had the same problem, but i figured out the solution: 'en_core_web_sm' : us ethis when you're not admin 'en' : can be used when you are admin. .

Linking fails because of admin rights over your system, but it's no big deal you can use the other counter-part.

kkairu commented 4 years ago

python -m spacy download en

@hamelsmu This works perfect on windows running anaconda

iamamjad commented 4 years ago

Try this hopefully it will work on my case i am using mac OS python -m spacy download en_core_web_lg

vipul2001 commented 4 years ago

While using command python -m spacy download en the package 'en_core_web_sm' automatically comes into the picture and get installed Also, it is better to use en_core_web_sm instead of en for models

raghav103 commented 4 years ago

@koliko are you running this code inside the provided docker container? if not, looks like you do not have spacy installed, so you will have to first install spacy

pip install spacy

Sir, I have installed spacy as well but it is still showing that there no module named spacy

raghav103 commented 4 years ago

@koliko are you running this code inside the provided docker container? if not, looks like you do not have spacy installed, so you will have to first install spacy

pip install spacy

@hamelsmu Sir, I have installed spacy as well but it is still showing that there no module named spacy

hamelsmu commented 4 years ago

Please search on stack overflow

marcelogere commented 4 years ago

Download successful but linking failed Creating a shortcut link for 'es' didn't work (maybe you don't have admin permissions?), but you can still load the model via its full package name: nlp = spacy.load('es_core_news_sm') This is how it worked for me!!! Thank you!!!

SamCurtis111 commented 4 years ago

This wasnt working for me after trying all of the above solutions. To make it work I did the following:

1) Right-click on Anaconda prompt -> run as administrator 1.1) python -m spacy download en 2) Right-click on Spyder -> run as admistrator Then once inside spyder (as admin) i was able to: import spacy nlp = spacy.load('en')

Zugamund commented 4 years ago

For those using Anaconda I found the following solution to install the en package and link it succesully:

  1. Right clik on the Anaconda Promt Icon
  2. Go to "More" and click on "Open as Administrator"
  3. Then type: python -m spacy download en

It worked for me

Thank so muuuuch SamCurtis111 !

sowmyaarajan commented 4 years ago

Hi, this got resolved when i opened the cmd prompt as an Administrator, kindly open anaconda as an admin and then run the same commands, it should work.

Yes! This works. Open the anaconda env as an administrator.

rajatscibi commented 3 years ago

For those using Anaconda I found the following solution to install the en package and link it succesully:

1. Right clik on the Anaconda Promt Icon

2. Go to "More" and click on "Open as Administrator"

3. Then type: `python -m spacy download en`

It worked for me

i tried everything and this worked finally!! thank you

Baludatascience commented 2 years ago

Hi, if still any one has issue with this, try to download with full name:

python -m spacy download en_core_web_sm --user

will work.

AndrexYT commented 1 year ago

Thanks,

@ClaudeCoulombe try this in your terminal

python -m spacy download en

does that work?

Thanks,it works for me.

No it says it can't link

Run console as admin!

KnightZhao commented 6 months ago

Hi, if still any one has issue with this, try to download with full name:

python -m spacy download en_core_web_sm --user

will work.

use this, new error ocurrs as follows: raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /explosion/spacy-models/master/shortcuts-v2.json (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002C088DB34E0>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed',))