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

ImportError: cannot import name 'GoldCorpus' #1953

Closed
oxinabox opened this issue Feb 8, 2018 · 9 comments
Closed

ImportError: cannot import name 'GoldCorpus' #1953

oxinabox opened this issue Feb 8, 2018 · 9 comments
Labels
install Installation issues

Comments

@oxinabox
Copy link
Contributor

oxinabox commented Feb 8, 2018

Having just installed spacy,
I can't seem to do anything as trying to import the package immediately throws the error:

ImportError: cannot import name 'GoldCorpus'

For example:

oxinabox@motsugo ~> python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/spacy/__init__.py", line 4, in <module>
    from .cli.info import info as cli_info
  File "/usr/local/lib/python3.4/dist-packages/spacy/cli/__init__.py", line 6, in <module>
    from .train import train
  File "/usr/local/lib/python3.4/dist-packages/spacy/cli/train.py", line 12, in <module>
    from ..gold import GoldCorpus, minibatch
ImportError: cannot import name 'GoldCorpus'

Or trying to use on the commandline:

oxinabox@motsugo ~> python3 -m spacy download en
/usr/bin/python3: Error while finding spec for 'spacy.__main__' (<class 'ImportError'>: cannot import name 'GoldCorpus'); 'spacy' is a package and cannot be directly executed

Your Environment

  • Operating System:

    • Debian GNU/Linux 8
    • Linux version 3.16.0-4-amd64 (gcc version 4.8.4 (Debian 4.8.4-1) ) failed on build #1 SMP Debian 3.16.51-2 (2017-12-03)
  • Python Version Used: Python 3.4.2 (default, Oct 8 2014, 10:45:20)

  • spaCy Version Used: 2.07

@honnibal
Copy link
Member

honnibal commented Feb 8, 2018

Hmm. I'd say this is either a problem with 3.4, or some sort of more general installation error. If you ls /usr/local/lib/python3.4/dist-packages/spacy, do you see the .so files? These should have the compiled modules, which is what spaCy will be importing.

@ines ines added the install Installation issues label Feb 8, 2018
@oxinabox
Copy link
Contributor Author

oxinabox commented Feb 8, 2018

oxinabox@motsugo /u/l/l/p/d/spacy> ls
about.py               language_data/                   strings.cpython-34m.so*
attrs.cpython-34m.so*  language.py                      strings.pxd
attrs.pxd              lemmatizer.py                    strings.pyx
attrs.pyx              lexeme.cpython-34m.so*           structs.pxd
bn/                    lexeme.pxd                       sv/
cfile.cpython-34m.so*  lexeme.pyx                       symbols.cpython-34m.so*
cfile.pxd              __main__.py                      symbols.pxd
cfile.pyx              matcher.cpython-34m.so*          symbols.pyx
cli/                   matcher.pyx                      syntax/
compat.py              _ml.py                           tagger.cpython-34m.so*
data/                  morphology.cpython-34m.so*       tagger.pxd
de/                    morphology.pxd                   tagger.pyx
deprecated.py          morphology.pyx                   tests/
displacy/              munge/                           tokenizer.cpython-34m.so*
en/                    nl/                              tokenizer.pxd
es/                    orth.cpython-34m.so*             tokenizer.pyx
fi/                    orth.pxd                         tokens/
fr/                    orth.pyx                         train.py
glossary.py            parts_of_speech.cpython-34m.so*  typedefs.pxd
gold.cpython-34m.so*   parts_of_speech.pxd              typedefs.pyx
gold.pxd               parts_of_speech.pyx              util.py
gold.pyx               pipeline.cpython-34m.so*         vectors.cpython-34m.so*
he/                    pipeline.pxd                     vectors.pyx
hu/                    pipeline.pyx                     vocab.cpython-34m.so*
__init__.pxd           pt/                              vocab.pxd
__init__.py            __pycache__/                     vocab.pyx
it/                    scorer.py                        zh/
lang/                  serialize/

@ines
Copy link
Member

ines commented Feb 9, 2018

This is interesting – did you previously have spaCy v1.x installed? Judging by the files and directories here, you seem to have a mix of spaCy v1.x and spaCy v2.0 in there. (For example, there's both the individual language directories like en in the root, as well as the lang submodule those were moved to in v2.0.)

It's possible that this is also what causes the problem. It's still kinda mysterious how this happened, but I guess the best solution is probably to uninstall spaCy and start again in a fresh environment.

@ines ines closed this as completed Feb 9, 2018
@ines ines reopened this Feb 9, 2018
@oxinabox
Copy link
Contributor Author

oxinabox commented Feb 9, 2018

This is interesting – did you previously have spaCy v1.x installed?

I did not.
Though actually I was installing a few things at the same time, (probably a bad idea thinking about that), and may have installed spaCy by mistake as a prereq.
And the whole system might have got a bit confused with two concurrent installed of the same package with different versions (I would have expected pip to use some kinda file lock to protect against that though)

@ines
Copy link
Member

ines commented Feb 9, 2018

Yeah, even if you did end up installing both spaCys, I would have expected pip to at least clean up properly. Anyway, I hope it all worked correctly after a fresh install!

@oxinabox
Copy link
Contributor Author

oxinabox commented Feb 9, 2018

Now I have different errors:

oxinabox@motsugo ~> python3 -m spacy download en
/usr/bin/python3: No module named spacy.__main__; 'spacy' is a package and cannot be directly executed

oxinabox@motsugo ~> python3 -m spacy.en.download
/usr/bin/python3: Error while finding spec for 'spacy.en.download' (<class 'ImportError'>: No module named 'spacy.language')
oxinabox@motsugo /u/l/l/p/d/spacy> ls
bn/                    en/  language_data/        __pycache__/            tests/
cfile.cpython-34m.so*  es/  munge/                serialize/              train.py
cfile.pxd              fi/  nl/                   sv/                     zh/
cfile.pyx              fr/  orth.cpython-34m.so*  syntax/
cli/                   he/  orth.pxd              tagger.cpython-34m.so*
de/                    hu/  orth.pyx              tagger.pxd
deprecated.py          it/  pt/                   tagger.pyx

I am going to give it another reinstall

@oxinabox
Copy link
Contributor Author

oxinabox commented Feb 9, 2018

seems like 3rd time is the charm

@oxinabox
Copy link
Contributor Author

oxinabox commented Feb 9, 2018

Sorted, soon other issues but they'll get their own threads

@oxinabox oxinabox closed this as completed Feb 9, 2018
@lock
Copy link

lock bot commented May 7, 2018

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 May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install Installation issues
Projects
None yet
Development

No branches or pull requests

3 participants