ImportError: cannot import name '_GenericAlias' from 'typing'
dnbo opened this issue · comments
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?
probably need to update to a new version of cattr, testing it out
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.
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
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...
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.