Python 3.8.10 error: got an unexpected keyword argument 'allowed_methods'

Hi There,

Using Python 3.8.10 on Ubuntu, and running into a peculiar problem for a simple code:

from square.client import Client
import os

client = Client(
    access_token=os.environ['SQUARE_ACCESS_TOKEN'],
    environment='sandbox')

result = client.locations.list_locations()

if result.is_success():
    for location in result.body['locations']:
        print(f"{location['id']}: ", end="")
        print(f"{location['name']}, ", end="")
        print(f"{location['address']['address_line_1']}, ", end="")
        print(f"{location['address']['locality']}")

elif result.is_error():
    for error in result.errors:
        print(error['category'])
        print(error['code'])
        print(error['detail'])

Error:

python3 test.py Traceback (most recent call last):
File β€œtest.py”, line 4, in
client = Client(
File β€œ/usr/local/lib/python3.8/dist-packages/square/client.py”, line 234, in init
self.config = Configuration(
File β€œ/usr/local/lib/python3.8/dist-packages/square/configuration.py”, line 68, in init
super().set_http_client(self.create_http_client())
File β€œ/usr/local/lib/python3.8/dist-packages/square/configuration.py”, line 103, in create_http_client
return RequestsClient(
File β€œ/usr/local/lib/python3.8/dist-packages/apimatic_requests_client_adapter/requests_client.py”, line 40, in init
self.create_default_http_client(timeout, cache, max_retries,
File β€œ/usr/local/lib/python3.8/dist-packages/apimatic_requests_client_adapter/requests_client.py”, line 69, in create_default_http_client
retries = Retry(total=max_retries, backoff_factor=backoff_factor,
TypeError: init() got an unexpected keyword argument β€˜allowed_methods’

Any suggestions as to why such error is occurring? Its occurring at the client connection phase.

I’m reaching out to the team about this. :slightly_smiling_face:

1 Like

Any update on this issue?

@getblokfarm, The team was able to reproduce the issue with an outdated version of urllib3 , which they suspect is the issue. Can you please run pip install -U urllib3 to upgrade the package? :slightly_smiling_face:

That worked! Thank you!

# pip install -U urllib3
Collecting urllib3
  Downloading urllib3-1.26.14-py2.py3-none-any.whl (140 kB)
     |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 140 kB 22.0 MB/s
Installing collected packages: urllib3
# python3 test.py
XXXXXXXXXXX: Default Test Account, 1600 Pennsylvania Ave NW, Washington

Glad to hear it worked. :slightly_smiling_face: