kahan robinson
kahan robinson

Reputation: 29

Can't run Venv in VsCode

For the last 3 days, I have been trying to set up virtual Env on Vs Code for python with some luck but I have a few questions that I cant seem to find the answer to.

  1. Does Vs Code have to run in WSL for me to use venv?
  2. When I install venv on my device it doesn't seem to install a Scripts folder inside the vevn folder. Is this out dated information or am I installing it incorrectly. I am installing onto Documents folder inside my D: drive using python3 - m venv venv. The folder does install and does run in WSL mode but I am trying to run it in clear VsCode so I can use other add-ons such as AREPL that doesn't seem to like being ran in WSL.

For extra context I have oh-my-ZSH set up and using the ubuntu command line on my windows device. Any information will be helpful at this point because I am losing my mind.

venv folder in side D: drive

result

Upvotes: 1

Views: 3662

Answers (4)

Abdulaziz Ebrahim
Abdulaziz Ebrahim

Reputation: 1

Run powershell as adminstrator
then excute this; Set-ExecutionPolicy RemoteSigned
then type; y Enter

Now you can activate in vs code without restrictions every time.

Upvotes: 0

Meenu
Meenu

Reputation: 179

Run Set-ExecutionPolicy Unrestricted -scope process before activating virtual environment.

All the best

Upvotes: 3

Brett Cannon
Brett Cannon

Reputation: 16000

You don't have to create a virtual environment under WSL, it will work anywhere. But the reason you don't have a Scripts/ directory is because (I bet) you're running VS Code with git bash and that makes Python think you're running under Unix. In that case it creates a bin/ directory. That will also confuse VS Code because the extension thinks you're running under Windows.

I would either create a virtual environment using a Windows terminal like PowerShell or Command Prompt or use WSL2.

Upvotes: 0

Omar Nasr
Omar Nasr

Reputation: 406

If you have the python extension installed you should be able to select your python interpreter at the bottom.

python interpreter selection at the bottom of vscode

You should then be able to select the appropriate path selecting the python interpreter

Upvotes: 2

Related Questions