subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024 with HikerAPI SaaS
https://hikerapi.com/p/bkXQlaVe
MIT License
4.42k stars 690 forks source link

[BUG] TypeError: unsupported operand type(s) for |: 'type' and 'type' #1719

Open Nickhenry784 opened 11 months ago

Nickhenry784 commented 11 months ago

Try Instagrapi SaaS with a free trial https://hikerapi.com/p/5GBWznd3

Describe the bug A clear and concise description of what the bug is.

To Reproduce Provide a piece of code to reproduce the problem.

Traceback Show your full traceback so that it is clear where exactly the error occurred.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here. Hello, I was testing your package and got this error. from instagrapi import Client

cl = Client() USERNAME = "abc" PASSWORD = "sdeerre"

cl.login(USERNAME, PASSWORD)

Error: Traceback (most recent call last): File "f:\Python\ins.py", line 1, in from instagrapi import Client File "~\Python\Python39\lib\site-packages\instagrapi__init__.py", line 7, in from instagrapi.mixins.account import AccountMixin File "~\Python\Python39\lib\site-packages\instagrapi\mixins\account.py", line 8, in from instagrapi.extractors import extract_account, extract_user_short File "~\Python\Python39\lib\site-packages\instagrapi\extractors.py", line 6, in from .types import ( File "~\Python\Python39\lib\site-packages\instagrapi\types.py", line 130, in class Media(BaseModel): File "~\Python\Python39\lib\site-packages\instagrapi\types.py", line 131, in Media pk: str | int TypeError: unsupported operand type(s) for |: 'type' and 'type'

enakhi commented 11 months ago

instad-web-1 | Traceback (most recent call last): instad-web-1 | File "/app/app.py", line 10, in instad-web-1 | from UserInfo import UserInfo instad-web-1 | File "/app/UserInfo.py", line 5, in instad-web-1 | from instagrapi import Client instad-web-1 | File "/usr/local/lib/python3.9/site-packages/instagrapi/init.py", line 7, in instad-web-1 | from instagrapi.mixins.account import AccountMixin instad-web-1 | File "/usr/local/lib/python3.9/site-packages/instagrapi/mixins/account.py", line 8, in instad-web-1 | from instagrapi.extractors import extract_account, extract_user_short instad-web-1 | File "/usr/local/lib/python3.9/site-packages/instagrapi/extractors.py", line 6, in instad-web-1 | from .types import ( instad-web-1 | File "/usr/local/lib/python3.9/site-packages/instagrapi/types.py", line 130, in instad-web-1 | class Media(BaseModel): instad-web-1 | File "/usr/local/lib/python3.9/site-packages/instagrapi/types.py", line 131, in Media instad-web-1 | pk: str | int instad-web-1 | TypeError: unsupported operand type(s) for |: 'type' and 'type' I have the same issue

tbass134 commented 11 months ago

I had the same issue. switching to python 3.11 works for me

Altimis commented 11 months ago

Switch to python 3.10

MaxRS07 commented 10 months ago

Hey guys, the issue comes from types.py in /Python/3.9/lib/python/site-packages/instagrapi/types.py. In line 125 the old union operator is used. change line 2 to from typing import List, Optional, Union and change line 25 to pk: Union[str, int]. repeat the same process anytime | is used. hope that makes sense lol.