#π .venv not activating
68 messages Β· Page 1 of 1 (latest)
@bold breach
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.
The venv is activated
You can see that by the (atreus) in the front.
However I would recommend to just activate it from the project folder:
source .venv/bin/activate
wdym?
Look at the pwd in blue
Just do cd ../..
lemme try it in WSL
Hmmm.
How did you create the venv?
Cause when I do this I get the expected result:
samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test$ python3 -m venv .venv
samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test$ cd .venv/
bin/ include/ lib/ lib64/
samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test$ cd .venv/bin
samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test/.venv/bin$ source activate
(.venv) samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test/.venv/bin$ cd ../..
(.venv) samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test$ which python
/home/samur/discordhelp/python-venv-test/.venv/bin/python
(.venv) samur@DESKTOP-S7666NN:~/discordhelp/python-venv-test$
Yeah, I see.
Can you try the following commands in your current terminal:
cd ~/Scripts
deactivate
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate
Maybe you made a small mistake while creating the venv, idk
Okay
Order of the first two commands doesn't matter
ah, I made a typo in the first one, but you figured out that I wanted to go to Scripts, okay
You don't need to cd into the .venv folder, but it shouldn't matter.
Hmmm. Very odd.
Can you type the following commands:
clear
deactivate
which py
which python
which python3
```and show the output?
ooooh. You have two separate Python installations that are probably conflicting with each other here
wait wha
Okay, please do:
clear
python --version
python3 --version
okay, it might just be an alias, but iirc I can't use python on my Linux machine (neither can i on my WSL).
Did you spend some time to intentionally set up an alias for python3 (i.e. that you can write python instead of python3?)
hmmm, also, why is your Python installed there? It should be in /usr/bin/python3
How did you install Python?
Id recommend using uv to simplify the usage of venv
Can you do:
ls -lha /home/atreus/bin | grep python
```and show the output?
And if you run:
ls -lha /usr/bin/ | grep python
```what do you get there?
hmm, idk.
One idea that I just had: Maybe it's just a visual thing.
If you do:
cat .venv/pyvenv.cfg
```inside your project folder, what is the output?
crazy, but it appears as if it's linking against the correct one.
Mine looks very similar:
Maybe it's just some weird case where you have installed Python in two locations, once in your /home/<your_name>/bin and once in the default /usr/bin folder.
Apparently if you have a /home/<your_name>/bin folder it will prefer that though.
So maybe this can just be fixed if you remove the /home/<your_name>/bin folder (or if it contains other stuff, just the python and python3 folders).
Make sure to make a backup of the folder first, though, e.g.:
cp -r /home/atreus/bin /home/atreus/bin_backup
rm -rf /home/atreus/bin
```then try to run this again:
```sh
which python
which python3
```and if it shows you `/usr/bin/python3` only, then you can immediately try to re-create the venv again with the steps I gave you here: [#1505214888274952364 message](/guild/267624335836053506/thread/1505214888274952364/p/1505214888274952364/#msg-1505217230990737528)
Oh okay
Sorry that I don't have a clear answer here, but this is quite an unusual error I have to say.
So best I can do is guide you along the error-hunting journey.
hmmm. okay. Still not quite what I have, but much closer.
Let's try the venv re-creation steps again: #1505214888274952364 message
btw, I'll be briefly gone for a smoke. I'll be back in 10-15 mins if noone else replaces me by then
ah wait, that looks good
What happened here?
Honestly: No clue π
Ok so it was treating home/atreus/bin as a default for virtual environment?
instead of home/usr/bin?
Thanks a lot for the help BTW. I was in a pretty rough mood. This helped a bit..
maybe? Not 100% sure tbh. As I said, I've never experienced this error before.
instead of
home/usr/bin?
NO! It's NOT/home/usr/bin. It's JUST/usr/bin, where/is the root folder.
Note that/is the root folder of the system, while~is your user's root folder, i.e.:
samur@DESKTOP-S7666NN:~$ cd /
samur@DESKTOP-S7666NN:/$ cd home/samur/
samur@DESKTOP-S7666NN:~$
```(Observe the current working directory and what it changes to).
So when you see `~/...` that's really just a shortcut for `/home/atreus/...` (or `/home/samur/...` in my case)
no worries
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.