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

cannot import name 'TypeGuard' from 'typing_extensions' #36

Open
Zakk-Yang opened this issue Dec 28, 2021 · 1 comment
Open

cannot import name 'TypeGuard' from 'typing_extensions' #36

Zakk-Yang opened this issue Dec 28, 2021 · 1 comment

Comments

@Zakk-Yang
Copy link

Zakk-Yang commented Dec 28, 2021

Use the following magic command in jupyter lab :
%load_ext lab_black

Got the following errorL

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/var/folders/dv/v74p4l3n109frg944h_3gdl80000gn/T/ipykernel_13307/1358876893.py in <module>
      1 # # code formartter
----> 2 get_ipython().run_line_magic('load_ext', 'lab_black')
      3 # # auto reloaded
      4 get_ipython().run_line_magic('load_ext', 'autoreload')
      5 

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2362                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2363             with self.builtin_trap:
-> 2364                 result = fn(*args, **kwargs)
   2365             return result
   2366 

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/IPython/core/magics/extension.py in load_ext(self, module_str)
     31         if not module_str:
     32             raise UsageError('Missing module name.')
---> 33         res = self.shell.extension_manager.load_extension(module_str)
     34 
     35         if res == 'already loaded':

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/IPython/core/extensions.py in load_extension(self, module_str)
     78             if module_str not in sys.modules:
     79                 with prepended_to_syspath(self.ipython_extension_dir):
---> 80                     mod = import_module(module_str)
     81                     if mod.__file__.startswith(self.ipython_extension_dir):
     82                         print(("Loading extensions from {dir} is deprecated. "

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/__init__.py in import_module(name, package)
    125                 break
    126             level += 1
--> 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 
    129 

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/_bootstrap.py in _gcd_import(name, package, level)

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/_bootstrap.py in _find_and_load(name, import_)

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/_bootstrap.py in _load_unlocked(spec)

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/_bootstrap_external.py in exec_module(self, module)

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/lab_black.py in <module>
     24 
     25 if sys.version_info >= (3, 6, 0):
---> 26     from black import format_str, FileMode
     27 
     28     def _format_code(code):

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/black/__init__.py in <module>
     47 from black.output import dump_to_file, ipynb_diff, diff, color_diff, out, err
     48 from black.report import Report, Changed, NothingChanged
---> 49 from black.files import find_project_root, find_pyproject_toml, parse_pyproject_toml
     50 from black.files import gen_python_files, get_gitignore, normalize_path_maybe_ignore
     51 from black.files import wrap_stream_for_windows

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/black/files.py in <module>
     25 from black.output import err
     26 from black.report import Report
---> 27 from black.handle_ipynb_magics import jupyter_dependencies_are_installed
     28 
     29 if TYPE_CHECKING:

/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/black/handle_ipynb_magics.py in <module>
     13     from typing import TypeGuard
     14 else:
---> 15     from typing_extensions import TypeGuard
     16 
     17 from black.report import NothingChanged

ImportError: cannot import name 'TypeGuard' from 'typing_extensions' (/opt/homebrew/Caskroom/miniforge/base/envs/tensorflow/lib/python3.8/site-packages/typing_extensions.py)
@charleneolive
Copy link

charleneolive commented Jan 2, 2022

Hello, did you manage to solve this error?

When I checked up, it was mentioned to upgrade typing extensions but I can't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants