python - python 中的 Instagram API 不起作用

标签 python module instagram instagram-api

安装了Anaconda,但它似乎没有Instagram模块。我安装了python,因为我的电脑上没有路径目录,并手动添加了instagram模块。尝试使用以下代码在 Anaconda 的 Spyder 和 Python 的 shell 中运行我的程序:

从 instagram.client 导入 InstagramAPI

access_token = "
client_secret = "
api = InstagramAPI(access_token=access_token, client_secret=client_secret)
recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
for media in recent_media:
   print (media.caption.text)

但总是收到错误(文件名为“main.py”)

from instagram.client import InstagramAPI
 ModuleNotFoundError: No module named 'instagram'

最佳答案

在尝试导入之前,您需要从 PyPi 安装 Instagram 库。

$ conda 安装 instagram -或者- $ pip install instagram

此外,您不应在互联网上发布客户端 secret 和访问 token 。实际上,这些与用户名和密码是一样的。

关于python - python 中的 Instagram API 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44856871/

相关文章:

javascript - 通过 Instagram 回复进行分页

javascript - Angular - 将指令附加到 future 元素

python - 遍历对象的 "public"属性

java - Ruby 模块是否等同于 Java 接口(interface)?

ruby - 如何访问 Ruby 中另一个模块内的模块中定义的方法?

javascript - 如何在特定主题标签中获取 Instagram 用户创建的帖子?

javascript - 像这样写图片和链接

python - 正确使用大广播变量的技巧?

python - Pandas 列差异,包含列表

javascript - React-Native 导入库并在多个组件中可用