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 'TypeAlias' from 'typing' Python3.8 fresh install #16

Open
tomcss opened this issue Feb 15, 2022 · 9 comments
Open

Comments

@tomcss
Copy link

tomcss commented Feb 15, 2022

When I try running cast_control, I get the error below. I tried installing through pip (0.11.8
.post0) and from github (0.11.9), but both times I get the same error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/mpris_server/types.py", line 5, in <module>
    from typing import \
ImportError: cannot import name 'TypeAlias' from 'typing' (/usr/lib/python3.8/typing.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/castctl", line 11, in <module>
    load_entry_point('cast-control==0.11.9', 'console_scripts', 'castctl')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/local/lib/python3.8/dist-packages/cast_control-0.11.9-py3.8.egg/cast_control/app/cli.py", line 11, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/local/lib/python3.8/dist-packages/cast_control-0.11.9-py3.8.egg/cast_control/base.py", line 11, in <module>
  File "/usr/local/lib/python3.8/dist-packages/mpris_server/__init__.py", line 1, in <module>
    from . import adapters, base, types, server, mpris, interfaces
  File "/usr/local/lib/python3.8/dist-packages/mpris_server/adapters.py", line 5, in <module>
    from .base import URI, MIME_TYPES, PlayState, DEFAULT_RATE, Microseconds, \
  File "/usr/local/lib/python3.8/dist-packages/mpris_server/base.py", line 10, in <module>
    from .types import TypedDict, TypeAlias, \
  File "/usr/local/lib/python3.8/dist-packages/mpris_server/types.py", line 11, in <module>
    from typing_extensions import \
ImportError: cannot import name '_GenericAlias' from 'typing_extensions' (/usr/local/lib/python3.8/dist-packages/typing_extensions.py)
@stegrams
Copy link

stegrams commented Feb 27, 2022

cast-control-0.11.8.post0
Python 3.8.10

In my case, the typing package lacks of TypeAlias and GenericAlias, and the typing-extensions package lacks of _GenericAlias.

I tried to use the _GenericAlias from the typing package, but it threw TypeError: 'type' object is not subscriptable from the mpris_server/base.py, line 15.

@stegrams
Copy link

Downgrading with:
sudo python3 -m pip uninstall cast_control
and
sudo python3 -m pip install cast_control==0.10.11
only works.
Every version between those, breaks with the same output.

@alexdelorenzo
Copy link
Owner

Thanks @tomcss for reporting this issue, and thanks @stegrams for providing a solution to it. I'm looking into this, but for the meantime @stegrams's solution might hold you over, as will a more recent version of Python.

@sbansiheng
Copy link

solved by
pip install typing-extensions --upgrade

@imozart987
Copy link

@sbansiheng Thanks very much!

@btbroot
Copy link

btbroot commented Jul 18, 2023

This resolution is impossible. As per https://docs.python.org/3/library/typing.html#typing.TypeAlias:

New in version 3.10.

So to workaround the original exception, one must upgrade Python to at least 3.10

@Rohith-sreedharan
Copy link

This also occurs using 3.8, the temp solution is not workable

@rtviii
Copy link

rtviii commented Dec 12, 2023

In my case it was incompatible versions of pydantic and django-ninja

@BharatPanera
Copy link

In my case the cast_control was not installed.
Thanks @stegrams for the solutions.

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

9 participants