subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.37k stars 684 forks source link

[BUG] TypeError when importing Client from instagrapi #1713

Open Ricardomol opened 10 months ago

Ricardomol commented 10 months ago

Describe the bug I get this error TypeError: unsupported operand type(s) for |: 'type' and 'type' just by simply importing Client, like this: from instagrapi import Client.

I'm running the script on Mac OS, have created a Python virtual env and installed instagrapi, like this:

python -m venv venv
source venv/bin/activate
pip install instagrapi
python test.py

To Reproduce

from instagrapi import Client

Traceback

Traceback (most recent call last):
  File "/Users/me/work/engager/instagrapi/test2.py", line 1, in <module>
    from instagrapi import Client
  File "/Users/me/work/engager/instagrapi/venv/lib/python3.9/site-packages/instagrapi/__init__.py", line 7, in <module>
    from instagrapi.mixins.account import AccountMixin
  File "/Users/me/work/engager/instagrapi/venv/lib/python3.9/site-packages/instagrapi/mixins/account.py", line 8, in <module>
    from instagrapi.extractors import extract_account, extract_user_short
  File "/Users/me/work/engager/instagrapi/venv/lib/python3.9/site-packages/instagrapi/extractors.py", line 6, in <module>
    from .types import (
  File "/Users/me/work/engager/instagrapi/venv/lib/python3.9/site-packages/instagrapi/types.py", line 130, in <module>
    class Media(BaseModel):
  File "/Users/me/work/engager/instagrapi/venv/lib/python3.9/site-packages/instagrapi/types.py", line 131, in Media
    pk: str | int
TypeError: unsupported operand type(s) for |: 'type' and 'type'

Expected behavior The Clientobject should be imported correctly.

Desktop (please complete the following information):

Ricardomol commented 10 months ago

I managed to move on by switching from Python 3.9 to 3.10. However, the docs say this is compatible with Python >= 3.9.

praveencqr commented 10 months ago

I installed it on Python 3.10 and it works fine now. Python 3.9 doesn't support the latest version.