#🔒 need help installing discord.py

76 messages · Page 1 of 1 (latest)

quartz spire
#

i got a code on visual studio code that has "import discord" and when i ran it it gave me an error of "no module called discord" so i tried to pip install discord.py but i keep getting

"note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for aiohttp
Failed to build aiohttp
ERROR: Failed to build installable wheels for some pyproject.toml based projects (aiohttp)"

so ive tried to pip install aiohttp and it still gave me error failed building wheel for aihttp and error failed to build installable wheels for some pyproject.toml... so what i then tried is to change my python version in VS to 3.12.8 yet still the same errors, ive seen online that some recommend downgrading to 3.10 so i tried to download 3.10.16 but it downloaded in a .tar.xz which i have no idea how to install from what should i do from here???

shell solarBOT
#

@quartz spire

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

quartz spire
#

my script is the following:

import discord
from discord.ext import commands
import asyncio

TOKEN = 'token' # Replace 'token' with discord token
bot = commands.Bot(command_prefix='!')

@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')

async def send_message():
channel = bot.get_channel(1341762802011865158) # Replace with channel ID
while True:
await channel.send("message")
await asyncio.sleep(10) # Wait X seconds
@bot.event
async def on_ready():
bot.loop.create_task(send_message())

bot.run(TOKEN)

stoic gorge
#

Are you using Windows or Linux?

quartz spire
#

windows 11

stoic gorge
#

Okay, you most likely just downloaded the wrong version of py 3.10

#

This one below should be the executable version

quartz spire
#

installing it now ill check if it works for me on VS and ill try to install discord.py with pip and ill come back

stoic gorge
#

Just make sure when running and installing you are on the 3.10 installation and not your newer one. Switch the VSCode environment and check python --version

quartz spire
#

yes okay, do you recommend adding .venv to 3.10? since i do have 3.12 and 3.13 normal and i have 3.14 pre release on .venv

stoic gorge
#

Yeah I would start a venv with 3.10

#

just to make it easier to distinguish

quartz spire
#

sounds good ill also do that

open jewel
#

Or is this the same?

quartz spire
#

well it isnt the same i think but aslong as i have a 3.10 then itll work, because looking back at the download page for 3.10.16 it seems like theres no windows install and only the tarball and tarball xz

quartz spire
#

yeah i just looked at it and it looks like 3.10.6 is the latest 3.10 with windows install for what ive seen so far

#

yeah all the way up to 3.10.11 has a windows install and anything under that hass a windows install, from 3.10.12 and higher it only has tarball

stoic gorge
#

Eitherway whatever 3.10 version you have should be fine

quartz spire
#

yeah im sure its fine

quartz spire
#

idk i just saw that online they said to download 3.10 so i figured to download 3.10.16 but i didnt know what tar.xz is and im assuming its for linux installs. i wasnt sure since im personally a beginner and most of my codes are made with help of aria ai

#

VS is now on 3.10.6.venv and im going to do pip uninstall discord.py and the pip install discord.py just to make sure that it doesnt try to install over what successfully installed before and corrupt

open jewel
#

Yea i hope it work now because you have now multiple versions of Python

quartz spire
#

one second here because i did pip install discord.py and it failed because when i tried to make 3.10.6 a .venv it for some reason just swapped to 3.14 so im retrying pip install discord.py on normal 3.10.6

#

its building the wheel right now which is usually where it goes wrong

#

...

#

hmmm

#

it did the same thing

#

also interesting amount of syntax errors ive just noticed now

#

im going to cls my terminal because its becoming a real cluster of mess

#

ive also noticed this

#

unsure what any of it means but i figure that it might be a part of the current problem i have

open jewel
#

Hmm, did you Relaunch the Terminal?

quartz spire
#

i just relauched

open jewel
#

Okay

quartz spire
#

it did fix some of it but i still have "Shell integration failed to activate" but im just going to ignore it and try to run pip install discord.py

#

okay... wait so successfully built aihttp wheel im now watching to see if it finishes

quartz spire
#

it did fully install everything and also it gave me a notice that theres a new pip so im going to upgrade pip and then try and run the code

#

still "no module called discord" for the import discord

#

im running pip install discord.py to just make sure its all okay

#

everything okay..

#

i have no clue whats happening

#

okay i think i might be onto something, looking at the pip download thing ive noticed that it installed the discord.py to a folder called "python314" which im assuming 314 means it downloaded on the 3.14???

#

im gonna try and switch back to 3.14.venv and try to see if the discord module is infact in 3.14

#

it didnt install on 3.14

quartz spire
#

while i was on 3.10.6

open jewel
open jewel
quartz spire
open jewel
#

Try in cmd

quartz spire
#

okay it did install through on the cmd

#

oh wait i think i have the modules now

#

i have another error tho but its not a module error

#

what does

#

Traceback (most recent call last):
File "c:\Users\thier\OneDrive\Intro Prog (IPI)\demo1.py", line 6, in <module>
bot = commands.Bot(command_prefix='!')
TypeError: BotBase.init() missing 1 required keyword-only argument: 'intents'

#

mean?

open jewel
#

Your bot needs intens like that i guess
intents = discord.Intents.default()

#

In your code

quartz spire
#

where do i put it in here?

import discord
from discord.ext import commands
import asyncio

TOKEN = '#####' # Replace '#####' with discord token
bot = commands.Bot(command_prefix='!')

@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')

async def send_message():
channel = bot.get_channel(1341762802011865158) # Replace with channel ID
while True:
await channel.send("X")
await asyncio.sleep(10) # Wait X seconds
@bot.event
async def on_ready():
bot.loop.create_task(send_message())

bot.run(TOKEN)

open jewel
#

You need this between token and bot = …

#

intents = discord.Intents.default()
intents.message_content = True

#

When your on Discord develop portal you have to enable under bot tap the Message Content Intent

quartz spire
#

i get the exact same error and i noticed that when i run it it loops the code but since the error is present it just loops and gives me the same error

shell solarBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.