没有名为 instapy 的模块

问题描述 投票:0回答:1
``# Import the InstaPy module and create a new session
from instapy import instapy
session = InstaPy()

# Log in to Instagram
session.login(username="", password="")

# Follow multiple users
users_to_follow = ["joshuaa.ag", "ramc.haran7519", "mandeepsdheer", "yeshvanshka", "mariaedwardsxifnrcodja",
                   "shubhamlodhi839", "nataliefirkowska", "frasesreais98", "iran.traderir", "_niki_chaki_",
                   "laxma.n9883", "wesleysampaio2023", "neysha.cuevas.73", "efrenndiaz", "sajid__iri", "abbygibson08",
                   "syds______knee", "tu_rubia_privv3", "jxchiu_jewelry", "jarodbannister9", "blaccheaven_events",
                   "mariaeazuaje15", "mileidy.rangel", "shya.mlal8926", "al__ageed", "mahesana_ni_hasti_302",
                   "randym518", "aashumathur7", "kingsxd99", "afdrtv4", "luljace_", "pi.ntukumar1434",
                   "raquel_lysette", "brooklynng33", "saraa.hhart", "its___mary___girl", "xavie_r7603",
                   "vaibhavrao2023", "r_usl_y", "donsmith5126", "rajeev141singh", "get0ffmyblick123", "sami_p1890",
                   "buck.eyboo", "nannhe3619", "imran__bhai_99gsb", "kabaddi____lover____baihar", "ronalperez11111"]
session.follow_users(usernames=users_to_follow)

# Unfollow users who don't follow back
session.unfollow_users(amount=10, nonFollowers=True, style="FIFO")

# Send a message to users who have the word "python" in their bio
session.send_message("hello", ["python"])

# Like posts that have the tag "python"
session.like_by_tags(["python"], amount=2)

# Comment on a post from the user "python"
user_id = session.get_user_id_from_username("python")
media_id = session.get_last_user_medias(user_id)[0]
session.comment(media_id, "This is very nice")

# Get the list of followers and following for the current user
followers_list = session.get_user_followers()
following_list = session.get_user_following()

`

`构建我的 Instagram 机器人后,它在第 2 行告诉它不会执行,因为我的代码中没有名为 instapy 的模块。我在将我的 Python 文件添加到环境变量后使用命令行安装了 instapy。``

python instagram-api
1个回答
0
投票

这里有一些东西可以用来调试为什么你的导入不起作用。假设你在 unix 环境中。鉴于缺乏信息,您用来执行代码的方法可能使用的 python 与您安装包的方法不同。

  1. which python
    。这将向您显示正在使用哪个 python 可执行文件来运行您的代码。
  2. where python
    。如果您安装了多个版本的 python,这将显示它们的位置。
  3. echo $PATH
    。这将向您显示您的路径,以及操作系统在其中查找 python 可执行文件的所有文件目录。这可以帮助您调试为什么您的 python 可执行文件是错误的(如果它是错误的)。
  4. pip list
    。这将向您显示您在命令行中使用的 python 程序中安装的所有 python 包。
© www.soinside.com 2019 - 2024. All rights reserved.