notion-py icon indicating copy to clipboard operation
notion-py copied to clipboard

Error when creating NotionClient

Open gloriouslyawkwardlife opened this issue 1 year ago • 2 comments

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'


gloriouslyawkwardlife avatar Jul 15 '24 23:07 gloriouslyawkwardlife

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!

michaelfromyeg avatar Aug 16 '24 16:08 michaelfromyeg

Actually, this repo does not seem updated, but this one uses the same core and is updated.

I ran some tests of the client and it works as expected

from csv2notion_neo.notion.client import NotionClient

# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in (non-guest) session on Notion.so
client = NotionClient(
    token_v2="<token_v2>",
    workspace="<workspace_name>")

theflysurfer avatar Nov 11 '24 19:11 theflysurfer