jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.28k stars 476 forks source link

Error when creating NotionClient #401

Open gloriouslyawkwardlife opened 2 months ago

gloriouslyawkwardlife commented 2 months ago

I have serious doubts that this is even an active project anymore, but in case:

>>> client = NotionClient(token_v2="<notion token_v2>")

File /opt/homebrew/lib/python3.12/site-packages/notion/client.py:77, in NotionClient.__init__(self, token_v2, monitor, start_monitoring, enable_caching, cache_key, email, password, client_specified_retry)
     66 def __init__(
     67     self,
     68     token_v2=None,
   (...)
     75     client_specified_retry=None,
     76 ):
---> 77     self.session = create_session(client_specified_retry)
     78     if token_v2:
     79         self.session.cookies = cookiejar_from_dict({"token_v2": token_v2})

File /opt/homebrew/lib/python3.12/site-packages/notion/client.py:39, in create_session(client_specified_retry)
     37     retry = client_specified_retry
     38 else:
---> 39     retry = Retry(
     40         5,
     41         backoff_factor=0.3,
     42         status_forcelist=(502, 503, 504),
     43         # CAUTION: adding 'POST' to this list which is not technically idempotent
     44         method_whitelist=(
     45             "POST",
     46             "HEAD",
     47             "TRACE",
     48             "GET",
     49             "PUT",
     50             "OPTIONS",
     51             "DELETE",
     52         ),
     53     )
     54 adapter = HTTPAdapter(max_retries=retry)
     55 session.mount("https://", adapter)

TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'
michaelfromyeg commented 4 weeks ago

I hit the same issue. Based on this discussion, it looks like a work-around is to downgrade urllib, i.e., run pip install 'urllib3<2'.

Can confirm after running this the repo works on Python 3.10!