Jupyter Notebook Python Error while Importing Spacy : No module named click._bashcomplete
Asked Answered
V

3

11

My notebook was working fine till 7 days back, which was the last time I touched it. Now I am getting this error.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-76a01d9c502b> in <module>
----> 1 import spacy

~\AppData\Roaming\Python\Python38\site-packages\spacy\__init__.py in <module>
     12 
     13 from . import pipeline  # noqa: F401
---> 14 from .cli.info import info  # noqa: F401
     15 from .glossary import explain  # noqa: F401
     16 from .about import __version__  # noqa: F401

~\AppData\Roaming\Python\Python38\site-packages\spacy\cli\__init__.py in <module>
      1 from wasabi import msg
      2 
----> 3 from ._util import app, setup_cli  # noqa: F401
      4 
      5 # These are the actual functions, NOT the wrapped CLI commands. The CLI commands

~\AppData\Roaming\Python\Python38\site-packages\spacy\cli\_util.py in <module>
      6 import srsly
      7 import hashlib
----> 8 import typer
      9 from click import NoSuchOption
     10 from click.parser import split_arg_string

~\AppData\Roaming\Python\Python38\site-packages\typer\__init__.py in <module>
     27 
     28 from . import colors as colors
---> 29 from .main import Typer as Typer
     30 from .main import run as run
     31 from .models import CallbackParam as CallbackParam

~\AppData\Roaming\Python\Python38\site-packages\typer\main.py in <module>
      9 import click
     10 
---> 11 from .completion import get_completion_inspect_parameters
     12 from .core import TyperArgument, TyperCommand
     13 from .models import (

~\AppData\Roaming\Python\Python38\site-packages\typer\completion.py in <module>
      8 
      9 import click
---> 10 import click._bashcomplete
     11 
     12 from .models import ParamMeta

ModuleNotFoundError: No module named 'click._bashcomplete'

UPDATE:

I reinstalled spacy. Now I am getting this error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-76a01d9c502b> in <module>
----> 1 import spacy

~\Anaconda3\lib\site-packages\spacy\__init__.py in <module>
      8 
      9 # These are imported as part of the API
---> 10 from thinc.neural.util import prefer_gpu, require_gpu
     11 
     12 from . import pipeline

ModuleNotFoundError: No module named 'thinc.neural'

I then reinstalled thinc but the error isnt going away. I will attempt the other answer suggested. I am typing more because stackoverflow isnt letting me save the edits because it says my post is mostly code.

EDIT 2:

Ok, so I re-installed spacy after reinstalling thinc and now it seems to be working. phew..

Valentinevalentino answered 15/6, 2021 at 13:48 Comment(3)
As a note: don't post screenshots, copy/paste your code.Kappenne
@Kappenne my code is literally just "import spacy"Valentinevalentino
@Kappenne ok I guess I can copy/paste the error instead of the screenshot. Got it. Thanks.Valentinevalentino
K
5

Uninstall click and spaCy and then reinstall spaCy. If possible it's better to start in a clean environment, but at a minimum just doing those two should work.

To clarify, this is happening because the latest version of click doesn't work with spaCy. spaCy specifies using an old click version, so that'll be installed when you install spaCy, but if you upgrade click on your own spaCy won't stop you.

Kappenne answered 16/6, 2021 at 6:46 Comment(0)
B
11

In my case, I installed the lower version of click.

pip install click==7.0

and after that, I get an error like 'Exit module not found' and installed it also

pip install Exit

Restarted my notebook and spacy gets imported without any errors.

Basicity answered 16/6, 2021 at 6:56 Comment(0)
K
5

Uninstall click and spaCy and then reinstall spaCy. If possible it's better to start in a clean environment, but at a minimum just doing those two should work.

To clarify, this is happening because the latest version of click doesn't work with spaCy. spaCy specifies using an old click version, so that'll be installed when you install spaCy, but if you upgrade click on your own spaCy won't stop you.

Kappenne answered 16/6, 2021 at 6:46 Comment(0)
W
0

I have same error after update "Anaconda Navigator". I simply updated spacy library with this commands:

pip install -U spacy
python -m spacy validate

Then restarted my notebook and spacy gets imported without any errors.

Wells answered 5/8, 2021 at 17:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.