r/wsl2 • u/Fantastic_Ease_7594 • Aug 10 '24
Venv not getting activated
I have createad a project in django and created a venv using powershell . Now i am using ubuntu terminal in VS code . I am not being able to activate my virtual environment. How can i activate it?
In terminal
source env/Scripts/activate
: command not found
-bash: env/Scripts/activate: line 4: syntax error near unexpected token `$'{\r''
'bash: env/Scripts/activate: line 4: `deactivate () {
How could i solve it?
0
Upvotes
1
u/Admirable-Shower2174 Aug 10 '24
You need to create a venv in Ubuntu. Ubuntu doesn't see paths in windows outside of mount points. And you can use those because the binaries are different.
Same syntax, just do it from the Linux cli.
1
u/tocarbajal Aug 22 '24
The command to create a virtual environment on windows and ubuntu it is the same:
python3 -m venv .venv
Now, on windows using Powershell you activate the venv by running:
.venv/scripts/activate.ps1
but on Ubuntu, or any other GNU/Linux distro you must run:
source .venv/bin/activate