explosion / spaCy

💫 Industrial-strength Natural Language Processing (NLP) in Python
https://spacy.io
MIT License
29.62k stars 4.36k forks source link

(Anaconda2) python -m spacy.en.download => No Module named attrs #253

Closed profversaggi closed 8 years ago

profversaggi commented 8 years ago

I've done a pip install attrs and am able to see it in the pip list, yet when I perform a python -m spacy.en.download I get No Module named attrs.

Any suggestions as to how to fix?

honnibal commented 8 years ago

Hmm.

attrs is (one of many) modules within spaCy. The error suggests to me that the module might not be being compiled?

Some debugging suggestions:

profversaggi commented 8 years ago

Pip List does NOT list spacy, only Conda list actually lists spacy?

I found that kind of odd - does it ring a bell?

Conda List give me 0.98 for SpaCY.

honnibal commented 8 years ago

What happens if you do which pip? It sounds to me like the pip you're executing is the system pip, not your anaconda pip. I sometimes get this due to pyenv. If you're using that pyenv rehash might fix you.

profversaggi commented 8 years ago

I'm on a win 2012 server environment - no 'which' cmd.

I'm fairly sure spacy isn't installed and so I did uninstall it via Conda just to make sure I'm working with a clean slate. I did set up the proper C++ env per the previous blog postings and got the pip install spacy --upgrade to compile jut fine (I put the stdint.h file in the C:\Program Files\Microsoft Visual Studio 10.0\VC\include dir).

Restarting the whole process now ...

profversaggi commented 8 years ago

Results after a clean install .... it doesn't seem like there was any install at all ....

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>pip install spacy --upgrade Collecting spacy Requirement already up-to-date: cymem<1.32.0,>=1.30 in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: preshed<0.47,>=0.46.1 in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: numpy in c:\anaconda2\lib\site-packages (from spacy) Collecting thinc<5.1.0,>=5.0.0 (from spacy) Requirement already up-to-date: six in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: text-unidecode in c:\anaconda2\lib\site-packages (from spacy) Collecting murmurhash<0.27,>=0.26 (from spacy) Requirement already up-to-date: cloudpickle in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: plac in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: ujson in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: sputnik<0.9.0,>=0.8.0 in c:\anaconda2\lib\site-packages (from spacy) Requirement already up-to-date: semver in c:\anaconda2\lib\site-packages (from sputnik<0.9.0,>=0.8.0->spacy) Installing collected packages: murmurhash, thinc, spacy Found existing installation: murmurhash 0.24 Cannot remove entries from nonexistent file c:\anaconda2\lib\site-packages\easy-install.pth

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>python -m spacy.en.download C:\Anaconda2\python.exe: No module named attrs

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>

Results of Pip List: (no Spacy) .... .... .... rope (0.9.4) scikit-image (0.11.3) scikit-learn (0.17) scipy (0.17.0) semver (2.3.1) setuptools (19.6.2) simplegeneric (0.8.1) singledispatch (3.4.0.3) six (1.10.0) snowballstemmer (1.2.1) sockjs-tornado (1.0.1) sphinx (1.3.5) sphinx-rtd-theme (0.1.9) sputnik (0.8.2) spyder (2.3.8) SQLAlchemy (1.0.11) statsmodels (0.6.1) sympy (0.7.6.1) tables (3.2.2) .... .... ...

profversaggi commented 8 years ago

I did download the ZIP file from: GITHUB/SPACY and tried the following ...

After going through the README-MSVC.txt I tried the cmds there, all worked except the last one:

Build steps:

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>pip install -e . Obtaining file:///C:/Users/versaggim/MarcentPlatformSetup/Software/spaCy-master Complete output from command python setup.py egg_info:

Error compiling Cython file:
------------------------------------------------------------
...
from cymem.cymem cimport Pool
from thinc.typedefs cimport weight_t
^
------------------------------------------------------------

syntax\transition_system.pxd:2:0: 'thinc\typedefs.pxd' not found
Processing gold.pyx
Traceback (most recent call last):
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\bin\cythonize.py", line 156, in <module>
    run(args.root)
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\bin\cythonize.py", line 147, in run
    process(base, filename, db)
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\bin\cythonize.py", line 113, in process
    preserve_cwd(base, process_pyx, root + '.pyx', root + '.cpp')
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\bin\cythonize.py", line 78, in preserve_cwd
    func(*args)
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\bin\cythonize.py", line 60, in process_pyx
    raise Exception('Cython failed')
Exception: Cython failed
Cythonizing sources
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\setup.py", line 220, in <module>
    setup_package()
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\setup.py", line 196, in setup_package
    generate_cython(root, 'spacy')
  File "C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master\setup.py", line 115, in generate_cython
    raise RuntimeError('Running cythonize failed')
RuntimeError: Running cythonize failed

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>

honnibal commented 8 years ago

What happens if you do pip install thinc?

profversaggi commented 8 years ago

That completed successfully .... but what does that do for the install?

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>pip install thinc Requirement already satisfied (use --upgrade to upgrade): thinc in c:\anaconda2\lib\site-packages\thinc-3.4.1-py2.7-win-amd64.egg Requirement already satisfied (use --upgrade to upgrade): murmurhash in c:\anaconda2\lib\site-packages\murmurhash-0.24-py2.7-win-amd64.egg (from thinc ) Collecting cymem==1.30 (from thinc) Collecting preshed==0.43 (from thinc) Downloading preshed-0.43.tar.gz (95kB) 100% |################################| 98kB 871kB/s Building wheels for collected packages: preshed Running setup.py bdist_wheel for preshed ... done Stored in directory: C:\Users\versaggim\AppData\Local\pip\Cache\wheels\a4\0d\6f\1a2b1d7ad4c6b32f8717433810280eaebdf16d8a76996df18d Successfully built preshed Installing collected packages: cymem, preshed Found existing installation: cymem 1.31.0 Uninstalling cymem-1.31.0: Successfully uninstalled cymem-1.31.0 Found existing installation: preshed 0.46.1 Uninstalling preshed-0.46.1: Successfully uninstalled preshed-0.46.1 Successfully installed cymem-1.30 preshed-0.43

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>

honnibal commented 8 years ago

Unfortunately pip install success is not always success =/

Can you additionally check that:

If both of those succeeds, try installing spaCy, and see whether it still complains...? I'm debugging blind here, so it's not easy to suggest the right thing.

honnibal commented 8 years ago

Ah, just saw --- that's thinc3.4.1

Try:

pip install --upgrade thinc

If that still doesn't give you thinc 5.0.4, try doing pip install --upgrade --no-cache-dir thinc

profversaggi commented 8 years ago

That got me this:

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>python Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org

import thinc print thinc.file** C:\Anaconda2\lib\site-packages\thinc-3.4.1-py2.7-win-amd64.egg\thincinit.py**

profversaggi commented 8 years ago

Interesting - that worked but the thinc version in Python does not seem to be altered - should I delete it and then reinstall it?

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>pip install --upgrade thinc Collecting thinc Requirement already up-to-date: preshed<0.47,>=0.46 in c:\anaconda2\lib\site-packages (from thinc) Requirement already up-to-date: cymem<1.32,>=1.30 in c:\anaconda2\lib\site-packages (from thinc) Collecting murmurhash<0.27,>=0.26 (from thinc) Requirement already up-to-date: numpy in c:\anaconda2\lib\site-packages (from thinc) Installing collected packages: murmurhash, thinc Found existing installation: murmurhash 0.24 Cannot remove entries from nonexistent file c:\anaconda2\lib\site-packages\easy-install.pth

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>python Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org **>>> import thinc

print thinc.file C:\Anaconda2\lib\site-packages\thinc-3.4.1-py2.7-win-amd64.egg\thincinit.py **

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>pip install --upgrade --no-cache-dir thinc Collecting thinc Downloading thinc-5.0.4.tar.gz (721kB) 100% |################################| 724kB 2.6MB/s Requirement already up-to-date: numpy in c:\anaconda2\lib\site-packages (from thinc) Collecting murmurhash<0.27,>=0.26 (from thinc) Downloading murmurhash-0.26.0.tar.gz Requirement already up-to-date: cymem<1.32,>=1.30 in c:\anaconda2\lib\site-packages (from thinc) Requirement already up-to-date: preshed<0.47,>=0.46 in c:\anaconda2\lib\site-packages (from thinc) Installing collected packages: murmurhash, thinc Found existing installation: murmurhash 0.24 Cannot remove entries from nonexistent file c:\anaconda2\lib\site-packages\easy-install.pth

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>python Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 14:26:21) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. Anaconda is brought to you by Continuum Analytics. Please check out: http://continuum.io/thanks and https://anaconda.org **>>> import thinc

print thinc.file C:\Anaconda2\lib\site-packages\thinc-3.4.1-py2.7-win-amd64.egg\thincinit.py**

honnibal commented 8 years ago

Hmm. That's pretty frustrating.

I can't easily say why the right one is installing and then the wrong one is being used. Honestly one of the reasons I like using virtualenv is that if the environment gets into some sort of weird state I can easily nuke it (rm -rf .env) and start again.

I'd say if you clean out those obsolete versions from the site-packages directory things should work, but I don't know what the root cause is here.

profversaggi commented 8 years ago

I wonder if it is the anaconda2 ....

C:\Users\versaggim\MarcentPlatformSetup\Software\spaCy-master>pip uninstall thinc Cannot remove entries from nonexistent file c:\anaconda2\lib\site-packages\easy-install.pth

honnibal commented 8 years ago

That looks broken, sure. I never really understood the whole .pth trickery that Python does though.

profversaggi commented 8 years ago

Is Anaconda2 v 2.7.X supported? Or should I go back to anaconda 1?

Actually - it looks like PIP in Anaconda2 is horribly broken ... going to wipe anaconda2 and see if I can go back to anaconda 1 - nothing is being installed. I just deleted thinc by hand and the pip install didn't even reinstall that so it's not installing anything at all ....

profversaggi commented 8 years ago

Checking write file permissions as possible culpret.....

capdevc commented 8 years ago

re: the initial problem with "No Module named attrs"

This will happen if you run the python -m spacy.en.download bit from within the spacy source directory.

So, if you clone the repo, pip install ., and then try to do the download from within the repo, you'll get that error message. Having said that, your install looks borked and I don't think this is your problem, but hopefully it will help others who find this issue.

profversaggi commented 8 years ago

I was able to get thinc to install once I manually installed a\ blank easy-install.pth f**ile in the anaconda2\lib\sitepackages - evidently with out that file pip won't install anything.

I'll redo the install and report my findings .... hold pls :-)

profversaggi commented 8 years ago

It's working ! I'm installing the english data with the python -m spacy.en.download cmd now ! :-)

Thanks for the assist! You guys are AWESOME! :-)

C:\Users\versaggim\MarcentPlatformSetup\Software> C:\Users\versaggim\MarcentPlatformSetup\Software>python -m spacy.en.download Downloading... Downloaded 519.05MB 100.00% 8.59MB/s eta 0s archive.gz checksum/md5 OK Model successfully installed.

C:\Users\versaggim\MarcentPlatformSetup\Software>

One last question - I'm running 0.98 successfully - what do I get if I upgrade to .10?

honnibal commented 8 years ago

The upgrade will give you:

profversaggi commented 8 years ago

Awesome - do you have docs on the multi-threading? Speed is a big issue for us ...

Can I keep all of my current code the same?

Will calls like this have to be refactored?

import spacy.en
from spacy.en import English, LOCAL_DATA_DIR
import os
data_dir = os.environ.get('SPACY_DATA', LOCAL_DATA_DIR)
nlp = English(data_dir=data_dir)
honnibal commented 8 years ago

We've tried hard to keep backward compatibility with everything in the docs, and some undocumented things that are now sort of in the API (and will be documented).

The LOCAL_DATA_DIR thing isn't great and we probably want to deprecate it. But I made sure it stayed there, to maintain backward compatibility. Let us know if any of your code breaks.

profversaggi commented 8 years ago

It did break .... :-(

However, to change my code is a snap since we're only talking going from:

import spacy.en from spacy.en import English, LOCAL_DATA_DIR import os data_dir = os.environ.get('SPACY_DATA', LOCAL_DATA_DIR) nlp = English(data_dir=data_dir)

to

from spacy.en import English nlp = English()

Which is actually an improvement ....

profversaggi commented 8 years ago

UPDATE: - I've upgraded and not yet used the multi-threading and have found it to be a LOT faster. Thank you gents! :-)

henningpeters commented 8 years ago

Btw: we just updated our conda packages to version 0.100.5, please install with conda install -c spacy spacy.

trmanish commented 7 years ago

Hi

I came across this issue and I am facing the same issue. I have anaconda installed on a big data platform (Spark/HDFS). I did condo install space and it did get installed in the folder as when I do

pip list

I do see the spacy lib there. Also I see gensim which i installed too.

But when I open up a jupyter notebook and do

import spacy

it says 'No module named spacy'

trmanish commented 7 years ago

It gave this when I was trying to import the package

>>> import spacy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mtripathi/anaconda2/lib/python2.7/site-packages/spacy/__init__.py", line 3, in <module>
    from . import en
  File "/home/mtripathi/anaconda2/lib/python2.7/site-packages/spacy/en/__init__.py", line 5, in <module>
    from ..language import Language
  File "/home/mtripathi/anaconda2/lib/python2.7/site-packages/spacy/language.py", line 11, in <module>
    from .tokenizer import Tokenizer
  File "spacy/strings.pxd", line 18, in init spacy.tokenizer (spacy/tokenizer.cpp:10453)
ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found
nooralahzadeh commented 7 years ago

I update my anaconda and got the same error as it mentioned above : ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found @trmanish any advice , Thanks

lock[bot] commented 6 years ago

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.