PIP says it installed a package, but actually did not
PIP says it installed a package, but actually did not
In pip 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. pycharm 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.
pip install discord
async def <name>():
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 discord and discord.py are installed, even when it raises an ImportError
.
ImportError
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("Startedn________________")
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.
cmd
C:Users*****>cd venv
C:Users*****venv>cd Scripts
C:Users*****venvScripts>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\venvlibsite-packagesdiscord__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:Users\venvlibsite-packagesdiscordclient.py", line 38, in <module>
from .state import ConnectionState
File "C:Users\venvlibsite-packagesdiscordstate.py", line 36, in <module>
from . import utils, compat
File "C:Users\venvlibsite-packagesdiscordcompat.py", line 32
create_task = asyncio.async
^
SyntaxError: invalid syntax
It can be due to different environment, you may accidentally checked to create new env, so you installed your package only globally.
– vishes_shell
Sep 9 '18 at 19:45
I do have python 3.6.6 and 3.7.0 installed. The exact same thing has happened with both, and I've "installed" it on both versions. @Tim
– Person
Sep 9 '18 at 19:45
@vishes_shell What?
– Person
Sep 9 '18 at 19:46
Go to File → Settings → Project Settings → Project Interpreter and check if discord.py is under there. Also look at the what interpreter is being user. If not there try using
pip install discord.py
rather than pip install discord
– Tim
Sep 9 '18 at 19:52
pip install discord.py
pip install discord
2 Answers
2
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.
Well, 0.16.X is the form I'm using, which I much prefer.
– Person
Sep 9 '18 at 20:14
(See second edit)
– Person
Sep 9 '18 at 20:17
> EDIT 2: delete the 0.0.2 discord. its not supposed to be there and is interfering with the import process. How?
– Person
Sep 14 '18 at 22:55
(See third edit)
– Person
Sep 14 '18 at 23:21
So... I was getting annoyed with the fact that it wasn't working. I decided to close pycharm, delete .idea
, and reload it. I did that, it didn't work. I deleted .idea
again, but before running it, changed the interpreter...
.idea
.idea
IT. WORKED.
I guess it didn't save the interpreter in .idea
properly...
.idea
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Check that you don't have more than one version of python installed and that pip is using one and pycharm the other
– Tim
Sep 9 '18 at 19:44