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):
- OS: [e.g. Ubuntu 21.04]
- Python version [e.g. 3.8.3]
- instagrapi version [e.g. 1.9.3, not "latest"]
- moveipy version if used
- imagemagick version if used
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'
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
I had the same issue. switching to python 3.11 works for me
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.