#πŸ”’ .venv not activating

68 messages Β· Page 1 of 1 (latest)

bold breach
rustic larkBOT
#

@bold breach

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.

paper juniper
#

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
bold breach
#

I want to activate it in the Scripts folder

#

which it doesn't show

paper juniper
#

wdym?

bold breach
#

Look at the pwd in blue

paper juniper
#

Just do cd ../..

paper juniper
#

lemme try it in WSL

bold breach
paper juniper
# bold breach

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$
bold breach
#

Like that

#

But I'm not getting .venv

#

in brackets

paper juniper
#

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

bold breach
#

Okay

paper juniper
#

Order of the first two commands doesn't matter

bold breach
paper juniper
#

ah, I made a typo in the first one, but you figured out that I wanted to go to Scripts, okay

paper juniper
# bold breach

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?
bold breach
#

okay

paper juniper
#

ooooh. You have two separate Python installations that are probably conflicting with each other here

bold breach
#

wait wha

paper juniper
#

Okay, please do:

clear
python --version
python3 --version
bold breach
paper juniper
#

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

paper juniper
bold breach
#

uhhh

#

I don't remember

#

It came with the distro

#

Pop_OS

real tulip
#

Id recommend using uv to simplify the usage of venv

paper juniper
# bold breach

Can you do:

ls -lha /home/atreus/bin | grep python
```and show the output?
bold breach
paper juniper
# bold breach

And if you run:

ls -lha /usr/bin/ | grep python
```what do you get there?
bold breach
#

Is there a script to check if I installed python the right way?

paper juniper
#

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?
bold breach
paper juniper
#

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)
bold breach
#

Oh okay

paper juniper
bold breach
paper juniper
#

btw, I'll be briefly gone for a smoke. I'll be back in 10-15 mins if noone else replaces me by then

bold breach
#

Done

paper juniper
#

ah wait, that looks good

bold breach
#

What happened here?

paper juniper
#

Honestly: No clue πŸ’

bold breach
#

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..

paper juniper
# bold breach Ok so it was treating `home/atreus/bin` as a default for virtual environment?

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)
bold breach
#

Ohhh

#

okay

#

thanks

rustic larkBOT
#
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.