Essentially I cannot seem to activate my virtualenv environment which I create.
I\'m doing this inside of windows powershell through using
scripts\\a
In powershell use
Scripts\activate.ps1
instead of activate.bat which doesn't work in powershell anymore.
also deactivate by just typing
deactivate
at the command prompt
If machine a 64 bit, open the x86 instance of PowerShell as Administrator & check (set) the execution policy. try this
Set-ExecutionPolicy Unrestricted
or
Set-ExecutionPolicy Unrestricted -Force
Based on the answers found here, I created a short tutorial for this with screenshots.
Hope it can help: https://github.com/harrywang/self-contained-project/wiki/How-to-setup-Python-3-virtual-environment-on-Windows-10
C:\path> Set-ExecutionPolicy - Scope CurrentUser
cmdlet Set-ExecutionPolicy at command pipeline position 1 Supply values for the following parameters: ExecutionPolicy: Unrestricted
C:\path> Scripts\activate.ps1
(new env)
C:\path> deactivate
C:\path>
This Worked
This worked for me:
You can simply open a normal (you do not need elevated access) cmd or powershell session (I use the embedded PS terminal in vscode) and type the following from the folder where the script file is e.g.: .venv\Scripts\Activate.ps1
:
powershell.exe -executionpolicy unrestricted -command .\Activate.ps1 -Scope CurrentUser
and then you can run the activate
command after that.
Note: This will only allow that specific Script to run, and only by your logged in user.
Delete the directory for that venv you created. And create a new one using the command:
python -m venv myvenv
Then see if the activate command works.