因此,我通过在项目文件夹中输入
,为在github页https://github.com/gtalarico/airtable-python-wrapper/blob/master/README.md上找到的 airtable-python-wrapper 安装了软件包。pip install airtable-python-wrapper
后来我写了以下脚本:
from airtable import Airtable
from pprint import pprint
base_key = 'mykey'
table_name = 'MyBase'
myVar = Airtable(base_key, table_name)
print(myVar)
运行时出现错误:
ImportError: cannot import name 'Airtable' from 'airtable' (unknown location)
有人知道为什么会这样吗?为什么无法识别 Airtable 类?我正在关注文档,所以我不明白问题是什么。预先感谢
答案 0 :(得分:1)
除非这是一个错误的构建,否则可能是由于文件或相邻文件名为airtable
造成的:
❯ python -m venv .venv
❯ source ./.venv/bin/activate
.venv ❯ pip install airtable-python-wrapper
.venv ❯ echo "from airtable import Airtable; print(Airtable)" > test.py
.venv ❯ python test.py
<class 'airtable.airtable.Airtable'>
.venv ❯ echo "from airtable import Airtable; print(Airtable)" > airtable.py
.venv ❯ python airtable.py
Traceback (most recent call last):
File "airtable.py", line 1, in <module>
from airtable import Airtable; print(Airtable)
File "/Users/gui_talarico/dev/repos/gtalarico/test/project/airtable.py", line 1, in <module>
from airtable import Airtable; print(Airtable)
ImportError: cannot import name 'Airtable' from 'airtable' (/Users/gui_talarico/dev/repos/gtalarico/test/project/airtable.py)