Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 423
Amatya Avatar asked Jun 15 '21 13:06

Amatya


People also ask

How do I install spacy 2?

# make sure you are using recent pip/virtualenv versions python -m pip install -U pip virtualenv git clone https://github.com/explosion/spaCy cd spaCy virtualenv . env source . env/bin/activate pip install -r requirements. txt pip install -e .


2 Answers

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.

like image 132
R.Bansal Avatar answered Oct 14 '22 09:10

R.Bansal


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.

like image 30
polm23 Avatar answered Oct 14 '22 09:10

polm23