【问题标题】:Instagram API in python doesn't workpython中的Instagram API不起作用
【发布时间】:2017-07-01 02:34:48
【问题描述】:

安装了 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'

【问题讨论】:

    标签: python module instagram instagram-api


    【解决方案1】:

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

    $ conda install instagram -要么- $ pip install instagram

    此外,您不应在互联网上发布客户端机密和访问令牌。实际上,它们与用户名和密码相同。

    【讨论】:

    • 谢谢,忘记了:|安装了 pypi instagram,那么我应该将它存储在哪里?很抱歉提出这样的问题
    • 我不确定我是否跟踪您的要求。我不确定它如何与 conda 一起工作,但使用pip,你不会“存储”已安装的库,包管理器会为你做这件事。您只需使用上述命令安装软件包,然后通过importing 使用该库。
    • 我试过了,它给了我这个:'conda' 不是内部或外部命令、可运行程序或批处理文件。
    • @AlinaDyussupova 你在使用 Anaconda 和 conda 吗?您可能想查看有关使用包管理器的文档。 conda.io/docs/using/pkgs.html。如果未安装 conda,您也可以尝试 pip install instagram
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多