So i'm trying to create this bot but i'm can't pass the venv wall. i'm super newbie and i'm trying my best to understand all the knowlegde i skiped. I think i was able to create a venv inside the folder programing/testing. And i placed a .env file in the token in the programing folder. the bot.py is also inside the programing folder. I don't know if i'm using the wrong interpreter or if i'm running in the wrong place but for some reason i can't make it work.
#π Trouble with venv.
95 messages Β· Page 1 of 1 (latest)
@lyric slate
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.
Closes after a period of inactivity, or when you send !close.
Trouble with venv.
okay. and what happens when you do python bot.py from the ~/Programming directory?
i'm not sure if you asking me this
yes, that
now try python -m pip install discord-py
perhaps you had it installed outside the venv
ok
You need to activate your venv before being able to run its main file with all the dependencies. Are you sure you've activated it here? I might be confused, but it doesn't look like it to me
ugh, right. VS Code doesn't activate the venv in its terminal automatically
yeah, you're gonna need to do that
i don't think i did no. i activated on Programing/testing
What's testing?
Oh it's the name of the venv
oh i'm sorry guys it's just a mess
So activate then try running bot.py again
Like go back to dir Programming then type
source testing/bin/activate
ok let me try
how can I @exotic lava . in the terminal i seem to be stuck on the (venv). i tried by using cd.. or cd Programing but i'm stuck.
i'm trying to do it in the VScode terminal btw
Anyway it looks like the venv is already activated so run python3 list to see if discord.py was correctly installed
Oh my bad run pip3 list
seems to be
Oh right you seem to use another package which you evidently didn't install
am i trolling or something? i know there's a file called .env with the token inside.
Yes but from dotenv import load_env only works of you installed the dotenv package
oh damn... the youtuber must already had installed
Go ahead and install it then
stupid question why are you using python3/pip3 inside a venv
Also last time I checked discord.py YouTube tutorials are horribly outdated
Um why
aren't python3/pip3 usually the systemwide installations in cases where systems still ran python 2 and python 3 alongside each other
dude i just love you bro
if you have a venv you should be able to just use python
Noted
and i'm actually suspicious now that you're not doing anything in the venv and doing everything in the user installation
oh do you think so?
can you show me the output of pip list (not pip3)
I am also not doing anything in Linux, I use Windows
Linux environment things are still foreign to me
Oh cool so from now on you can do python bot.py and pip ... whenever you activate your venv
Still haven't installed dotenv
python-dotenv is there
You're right π
it's there but i installed using pip3 no problem right? it1s theere anyway
well python venvs are confusing but it's better to keep project specific dependencies to the venv rather than the system installation, that's why I want to be careful
last thing to check, run deactivate, then do pip list again
ok seems everything is fine
reactivate your venv now
by the way usually the venv directory is called .venv so it's easy to tell where it is without guessing what "testing" is
sure i'll change it
i don't remember if it's ok to just rename it, you might have to recreate the venv for it to work
i mean the process that i just learn with you awesome people i'll just do all over again.
well hold on then
Some scripts are installed with a shebang line with an absolute path so best recreate if you want to rename
the correct process is to have your main dependencies written down somewhere so you could recreate a venv very easily
specifically, create a requirements.txt file first where you can write discord.py and whatever else you use with their versions
specifically you can run pip freeze and copy the lines of the stuff you use directly
so with a pip freezei would have the main dependencies writed down for me? i'm leaning the words still
It creates a requirements.txt file with all the packages installed in the environment
no, pip freeze will give you the list of all packages installed and their versions, not all of these are main dependencies, some of them are installed because your dependencies depend on them, you don't need to save them
so you have to pick out the stuff you're using directly to copy to the requirements.txt
Which I believe are just discord.py and python-dotenv in your case so far
yeah yeah i just saw it
yo guys thank you very much once again. for your time and care. thank you so much
You're welcome
@lyric slate did you create the file?
yes i think i did just like u said. i created a requirements.txt file and added the things i installed
like this
now if you delete your old venv and create a new one (called .venv), you'll be able to install all the same stuff by running pip install -r requirements.txt
that's why these days we hold that venvs should be cattle, not pets - you should be able to delete them and recreate them easily
that's why we expect them to be in .venv
ooh alright. that's a good way of picturing it. cattle got no names
dude i'm getting beaten down by linux and python bro. but it's just awesome to see how things works.
god bless the community for real
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.