Person
Person

Reputation: 379

PIP says it installed a package, but actually did not

In I simply typed pip install discord. If I tried again, which I did, it responds like in the image. But python says it isn't installed. says the async def <name>(): is okay, which has never happened before without discord imported correctly (It checks for that). PyCharm also usualy tells me when a module isn't installed. This Was not happening yesterday, but all of a sudden now.

Screenshot Any help would be much, much appreciated as the server this bot runs on hates it when it's offline.

EDIT:

After trying @javajavs' answer, it's still doing the same thing. Except this time it says that and are installed, even when it raises an ImportError.

#2

EDIT 2:

I'll include the source code here for reference:

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")

Edit 3:

So, after a while of thinking, I went into cmd and tryed to run pip from the venv folder.

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

It installed it..? I tried to run the program, but it raised an error...

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

Upvotes: 3

Views: 671

Answers (2)

Person
Person

Reputation: 379

So... I was getting annoyed with the fact that it wasn't working. I decided to close , delete .idea, and reload it. I did that, it didn't work. I deleted .idea again, but before running it, changed the interpreter...

IT. WORKED.

I guess it didn't save the interpreter in .idea properly...

Upvotes: 0

javajav
javajav

Reputation: 379

if you are using an environment created by pycharm, downloading discord.py onto your regular python folder wont help since they use two different python environments. go to settings > project: > Project interpreter and press the green plus on the right side of the screen. now type the name of the module (discord.py) and download the one you need. hit apply. now you have discord.py installed.

EDIT: you installed the 0.16 version. you may want to delete it and download the 1.X.X version since thats the one you seem to be using.

EDIT 2: delete the 0.0.2 discord. its not supposed to be there and is interfering with the import process.

Upvotes: 5

Related Questions