【问题标题】:Why is airtable-python-wrapper not working?为什么 airtable-python-wrapper 不起作用?
【发布时间】:2019-03-20 10:23:04
【问题描述】:

所以我安装了 airtable-python-wrapper 的包,在 github 页面 https://github.com/gtalarico/airtable-python-wrapper/blob/master/README.md 上通过输入我的项目文件夹:

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?我正在关注文档,所以我不明白问题是什么。提前致谢

【问题讨论】:

  • pip install airtable-python.wrapper,带点?
  • 可能是python版本?尝试在 Python 2 和 3 上执行该脚本
  • @Shinratensei 感谢您的回答!为什么要使用点插入 - 因为文档建议使用命令 pip install airtable-python-wrapper
  • 正是我要问你的,因为在你的问题中你已经像我一样写了它。我想你只是在写它的时候打错了,它不在你的代码中,但仍然
  • @Shinratensei 哦,对不起,我更正了!如何使用 Python 2 运行脚本?我应该安装 Python 2 吗?

标签: python python-requests airtable


【解决方案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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-13
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    • 2021-07-01
    • 2023-03-24
    相关资源
    最近更新 更多