0

因此,我通过在我的项目文件夹中输入以下内容安装了在 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?我正在关注文档,所以我不明白问题是什么。提前致谢

4

1 回答 1

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)
于 2020-09-23T21:55:24.407 回答