gtalarico / pyairtable

Python Api Client for Airtable
https://pyairtable.readthedocs.io
MIT License
786 stars 139 forks source link

Error using sample #317

Closed gismcieri closed 12 months ago

gismcieri commented 12 months ago

Hi,

Installed pyairtable a few days ago and have tried on and off to connect to my environment using the code sample from the docs page

import os
from pyairtable import Api
api = Api(os.environ['AIRTABLE_API_KEY'])
table = api.table('appExampleBaseId', 'tblExampleTableId')
print (table.all())

and i always get the following error. I have tried various different things to get it to work and have been unsuccessful.

Traceback (most recent call last): File "Pathtofile\pyairtableTesting.py", line 2, in from pyairtable import Api File "C:\miniforge3\envs\main37\lib\site-packages\pyairtable__init.py", line 3, in from .api import Api, Base, Table File "C:\miniforge3\envs\main37\lib\site-packages\pyairtable\api\init__.py", line 1, in from .api import Api File "C:\miniforge3\envs\main37\lib\site-packages\pyairtable\api\api.py", line 223 if not (offset := response.get(offset_field)): ^ SyntaxError: invalid syntax

Am I missing something?

Thanks in advance, Matt

mesozoic commented 12 months ago

It looks like you are running Python 3.7, which reached end-of-life in June 2023. If upgrading to a supported version of Python is not possible, you will need to pin your project's dependencies to the 1.x version of this library, with a version specifier like pyairtable~=1.5 or pyairtable>=1.5,<2.0

If you choose that path, note that the API changed in 2.0, so you'll want to refer to the documentation for the 1.5.0 release instead: https://pyairtable.readthedocs.io/en/1.5.0/getting-started.html

gismcieri commented 12 months ago

Thanks so much. Can't believe I missed that. Everything is working as expected now.

Matt