#๐Ÿ”’ agent Q

121 messages ยท Page 1 of 1 (latest)

proper kelpBOT
#

@honest sable

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.

cunning robin
#

Are you on python 3.13?

honest sable
cunning robin
#

Use 3.12 for now; discord.py uses audioop which was removed in 3.13

solemn walrus
#

In this terminal, type ls and hit enter and show us the output

honest sable
solemn walrus
#

So basically if you run py test/test.py that should work

#

But as code golfing enthusiast says, you need the audioop to work

honest sable
tropic sand
#

Updating discord.py or installing audioop-lts should fix this.

honest sable
solemn walrus
cunning robin
#

I would py -m pip just to be safe

honest sable
solemn walrus
honest sable
solemn walrus
proper kelpBOT
#
Virtual environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
cunning robin
honest sable
solemn walrus
cunning robin
honest sable
#

wait so what am i supposed to be doing

#

and where

solemn walrus
#

First, set up a virtual env.
Second, either upgrade your discord.py or install audioop-lts in your virtual env

honest sable
#

ok how to i set up virtual env

solemn walrus
cunning robin
#

(is it really necessary to use a venv?)

solemn walrus
#

Its best practice to do so

honest sable
solemn walrus
honest sable
#

im not really sure

cunning robin
honest sable
#

alr i did that

#

now how do i run it?

solemn walrus
# proper kelp

Its been explained here, isn't it? Hopefully OP understood it โ˜๏ธ

honest sable
cunning robin
solemn walrus
#

Fair

honest sable
#

its still giving me the same error about cant open file no such file or directory

honest sable
#

i know that the file exists

#

but the app doesnt think it does

solemn walrus
honest sable
solemn walrus
#

python3 test/test.py

honest sable
solemn walrus
#

rerun the install upgrade command

honest sable
#

twice

solemn walrus
honest sable
#

idk what virtualenv is or how to install it

solemn walrus
#

Do you want to use a virtualenv or do you just want your bot to run?

winged lotus
#

you can't want to use something that you have no idea what it is

solemn walrus
honest sable
#

yeah im ngl idk what virtualenv is or what it does

winged lotus
#

a beginner does not have the ability to understand that, Agent Q

honest sable
#

again, im like a toddler to this stuff

solemn walrus
#

Then can't really help if you don't ask

winged lotus
solemn walrus
solemn walrus
honest sable
solemn walrus
honest sable
solemn walrus
honest sable
#

i just said it wrong

solemn walrus
#

python3 -m pip install -r requirements.txt

honest sable
#

in cmd?

solemn walrus
#

yes

honest sable
#

no txt

solemn walrus
honest sable
#

ohh

solemn walrus
honest sable
#

gotchu

solemn walrus
solemn walrus
# honest sable

You said the requirements.txt file is in that folder. But the terminal says its not there.

solemn walrus
honest sable
#

ohh i thought you were asking where the testr folder is

#

i was saying it was in the dscrd folder

solemn walrus
honest sable
#

thats it

#

thats all in there

solemn walrus
#

Can you share your test.py file code in a pastebin?

honest sable
proper kelpBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

honest sable
#

import discord
from discord.ext import commands

client = commands.bot(command_prefix = '!')

@client.event
async def on_ready():
print ("The bot is now ready for use")
print ("------------------------------")

@client.command()
async def hello (ctx):
    await ctx.send ("Hello, hi!")

client.run('insert bot token')

solemn walrus
honest sable
solemn walrus
#

You have 2 different Python versions installed

#

And this could have been avoided if you have a virtualenv installed

solemn walrus
# honest sable

Just do these commands:

python3 -m pip install -U discord.py

python3 test/test.py
honest sable
solemn walrus
#

its Bot

#

Are you following a tutorial somewhere?

honest sable
#

I followed a tutorial to write the little bit of code

solemn walrus
#

best of luck!

honest sable
#

dawg

proper kelpBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.