代码之家  ›  专栏  ›  技术社区  ›  Person

PIP说它安装了一个包,但实际上没有

  •  3
  • Person  · 技术社区  · 7 年前

    pip install discord . 如果我再试一次,我做到了,它的反应就像在图像中。但是python说它没有安装。 async def <name>(): 没有 不和谐导入正确(它检查)。PyCharm通常也会告诉我什么时候没有安装模块。这不是真的 ,但突然之间。

    Screenshot 任何帮助都会非常感谢,因为这个机器人运行的服务器讨厌它离线。

    编辑:

    安装,即使它引发 ImportError .

    #2

    编辑2:

    我将在此处包含源代码以供参考:

    import discord
    import random
    import Utilities as util
    import sys
    
    client = discord.Client()
    
    logs = []
    
    #global giveaway
    #giveaway = util.giveaway.Giveaway()
    
    cats = ["https://media.giphy.com/media/l3q2SKnzUMdELQkpi/giphy.gif", "https://media.giphy.com/media/TA6Fq1irTioFO/giphy.gif", "https://media.giphy.com/media/ORBjACSOzSYq4/giphy.gif", "https://giphy.com/gifs/cat-2QHLYZFJgjsFq?utm_source=media-link&utm_medium=landing&utm_campaign=Media%20Links&utm_term="]
    @client.event
    async def on_message(message):
      global logs#, giveaway
      message.content = str(message.content)
      if message.content.startswith("-pet"):
        await client.send_message(message.channel, "{0}, {1} is petting you! \n {2}".format("Catto", str("<@"+message.author.id+">"), random.choice(cats)))
      if message.author == client.user:
        return
      if str(message.author) == "𝖍𝖞𝖕𝖊𝖗#7136": # Admin Bot Commands
        if message.content.startswith("::stop"):
          for i in logs:
            await client.delete_message(i)
          client.close()
          sys.exit()
        elif message.content.startswith("::restart"):
          for i in logs:
            await client.delete_message(i)
          os.system("start src.py")
          client.close()
          sys.exit()
    
        if message.author == client.get_server("473895210762371072").get_member("269340844438454272"):
          if message.content.startswith("g-end"):
            await client.send_message(message.channel, "Congragulations, <@{0}>! You've won {1}!".format(giveaway.chooseWinner().id, giveaway.reward))
            giveaway.delete()
      if message.channel == client.get_channel("488097503128977458"):
        """if message.content.startswith("g-join"):
          if message.author not in giveaway.contestants:
            giveaway.contestantJoin(message.author)
            print("\n"*100)
            for i in giveaway.contestants:
              print(str(i))
          else:
            await client.send_message(message.author, "You cant enter more than once!!")
        """
        await client.delete_message(message)
    
    @client.event
    async def on_ready():
      global logs
      print("Started\n________________")
      logs.append(await client.send_message(client.get_channel("485891955717308436"), "`{0}`".format(util.initmsg)))
      """
      embed=discord.Embed(title="Giveaway!", description="Prize: {0}".format(giveaway.reward))
      embed.set_thumbnail(url="https://media.giphy.com/media/goGe7aJXfmEtW/giphy.gif")
      embed.add_field(name="Winners:", value=giveaway.winners, inline=True)
      embed.set_footer(text="Created by Hyper#7136")
      await client.send_message(client.get_channel("488097503128977458"), embed=embed)
      """
    client.run("token")
    

    编辑3:

    所以,经过一段时间的思考,我进入了 cmd

    C:\Users\*****\>cd venv
    C:\Users\*****\venv>cd Scripts
    C:\Users\*****\venv\Scripts>pip3 install discord
    

    它安装了它。。?我试着运行程序,但出现了一个错误。。。

    Traceback (most recent call last):
      File "C:/Users//Desktop/Spooper/src.py", line 1, in <module>
        import discord
      File "C:\Users\\venv\lib\site-packages\discord\__init__.py", line 20, in <module>
        from .client import Client, AppInfo, ChannelPermissions
      File "C:\Users\\venv\lib\site-packages\discord\client.py", line 38, in <module>
        from .state import ConnectionState
      File "C:\Users\\venv\lib\site-packages\discord\state.py", line 36, in <module>
        from . import utils, compat
      File "C:\Users\\venv\lib\site-packages\discord\compat.py", line 32
        create_task = asyncio.async
                                  ^
    SyntaxError: invalid syntax
    
    2 回复  |  直到 7 年前
        1
  •  5
  •   javajav    7 年前

    如果您使用的是pycharm创建的环境,请下载不和谐.py放在常规python文件夹中不会有帮助,因为它们使用两种不同的python环境。转到“设置”>“项目”>“项目解释器”,然后按屏幕右侧的绿色加号。现在输入模块的名称(不和谐.py)下载你需要的。点击应用。现在你有了不和谐.py安装。

    编辑:您安装了0.16版本。您可能需要删除它并下载1.X.X版本,因为您似乎正在使用1.X.X版本。

    编辑2:删除0.0.2不一致。它不应该在那里,而且正在干扰进口过程。

        2
  •  0
  •   Person    7 年前

    所以。。。我对它不起作用感到恼火。我决定关门 ,删除 .idea ,然后重新加载。我这么做了,没用。我删除了 .想法 再一次,但在运行它之前,换了一个解释器。。。

    是的。工作。

    我想这并没有把翻译救出来 正确地。。。