ImportError: cannot import name '_GenericAlias' from 'typing' #138

Closed
by dnbo opened 4 years ago · 5 comments
dnbo commented 4 years ago (Migrated from github.com)
Owner

Cloned the repository, ran pip3 install --user . and then tried to run it using Python 3.7 and got the following error:

 File "/<user>/Python/3.7/bin/deletefb", line 5, in <module>
    from deletefb.deletefb import run_delete
  File "/<user>/Python/3.7/lib/python/site-packages/deletefb/deletefb.py", line 4, in <module>
    from .tools.likes import unlike_pages
  File "/<user>/Python/3.7/lib/python/site-packages/deletefb/tools/likes.py", line 1, in <module>
    from .archive import archiver
  File "/<user>/Python/3.7/lib/python/site-packages/deletefb/tools/archive.py", line 8, in <module>
    import cattr
  File "/<user>/Python/3.7/lib/python/site-packages/cattr/__init__.py", line 2, in <module>
    from .converters import Converter, UnstructureStrategy
  File "/<user>/Python/3.7/lib/python/site-packages/cattr/converters.py", line 15, in <module>
    from ._compat import (
  File "/<user>/Python/3.7/lib/python/site-packages/cattr/_compat.py", line 31, in <module>
    from typing import List, Union, _GenericAlias
ImportError: cannot import name '_GenericAlias' from 'typing' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py)

Run on Mac OSX 10.15.16.

Something incompatible with 3.7?

Cloned the repository, ran `pip3 install --user .` and then tried to run it using Python 3.7 and got the following error: ``` File "/<user>/Python/3.7/bin/deletefb", line 5, in <module> from deletefb.deletefb import run_delete File "/<user>/Python/3.7/lib/python/site-packages/deletefb/deletefb.py", line 4, in <module> from .tools.likes import unlike_pages File "/<user>/Python/3.7/lib/python/site-packages/deletefb/tools/likes.py", line 1, in <module> from .archive import archiver File "/<user>/Python/3.7/lib/python/site-packages/deletefb/tools/archive.py", line 8, in <module> import cattr File "/<user>/Python/3.7/lib/python/site-packages/cattr/__init__.py", line 2, in <module> from .converters import Converter, UnstructureStrategy File "/<user>/Python/3.7/lib/python/site-packages/cattr/converters.py", line 15, in <module> from ._compat import ( File "/<user>/Python/3.7/lib/python/site-packages/cattr/_compat.py", line 31, in <module> from typing import List, Union, _GenericAlias ImportError: cannot import name '_GenericAlias' from 'typing' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/typing.py) ``` Run on Mac OSX 10.15.16. Something incompatible with 3.7?
weskerfoot commented 4 years ago (Migrated from github.com)
Owner

probably need to update to a new version of cattr, testing it out

probably need to update to a new version of cattr, testing it out
weskerfoot commented 4 years ago (Migrated from github.com)
Owner

I couldn't reproduce using 3.7.0, which version of cattrs are you using? pip show cattrs-3.8

I might also just switch back to mainline cattrs since it sounds like it will finally work with 3.9 soon. https://github.com/Tinche/cattrs/issues/100 This was the reason I switched to a fork in the first place.

I couldn't reproduce using 3.7.0, which version of cattrs are you using? `pip show cattrs-3.8` I might also just switch back to mainline cattrs since it sounds like it will finally work with 3.9 soon. https://github.com/Tinche/cattrs/issues/100 This was the reason I switched to a fork in the first place.
weskerfoot commented 4 years ago (Migrated from github.com)
Owner

Also, try it using the virtualenv method.

cd DeleteFB
virtualenv -p $(which python3) ./venv
source ./venv/bin/activate
pip install -r requirements.txt
python -m deletefb.deletefb <your args here>

this should work, since it's using the exact versions I am

Also, try it using the virtualenv method. ``` cd DeleteFB virtualenv -p $(which python3) ./venv source ./venv/bin/activate pip install -r requirements.txt python -m deletefb.deletefb <your args here> ``` this should work, since it's using the exact versions I am
weskerfoot commented 4 years ago (Migrated from github.com)
Owner

What is strange, is that the typing module contains _GenericAlias in the source code for 3.7, so it should work regardless of what other versions of things you have installed. See https://github.com/python/cpython/blob/3.7/Lib/typing.py#L599. It might be that it's actually missing in your specific version, so updating to a later version of 3.7 might fix the problem...

What is strange, is that the `typing` module contains `_GenericAlias` in the source code for 3.7, so it should work regardless of what other versions of things you have installed. See https://github.com/python/cpython/blob/3.7/Lib/typing.py#L599. It might be that it's actually missing in your specific version, so updating to a later version of 3.7 might fix the problem...
dnbo commented 4 years ago (Migrated from github.com)
Poster
Owner

Also, try it using the virtualenv method.

cd DeleteFB
virtualenv -p $(which python3) ./venv
source ./venv/bin/activate
pip install -r requirements.txt
python -m deletefb.deletefb <your args here>

this should work, since it's using the exact versions I am

This did it for me. Strange, because I thought this was what I was doing, but perhaps not.

pip show cattrs-3.8 returned 0.9.1 for me for the record.

> Also, try it using the virtualenv method. > > ``` > cd DeleteFB > virtualenv -p $(which python3) ./venv > source ./venv/bin/activate > pip install -r requirements.txt > python -m deletefb.deletefb <your args here> > ``` > > this should work, since it's using the exact versions I am This did it for me. Strange, because I thought this was what I was doing, but perhaps not. `pip show cattrs-3.8` returned `0.9.1` for me for the record.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.