skip to Main Content

I’ve made a virtual environment that looks like this:
enter image description here

When I run the following line it gives me an error:

PS C:UsersuserDocumentsCodeflaskTutorial> envScriptsactivate

But when I run this line nothing happens?

PS C:UsersuserDocumentsCodeflaskTutorial> envScriptsactivate.bat

I’ve read that windows doesnt run .bat files, but how do I activate my environment in vscode terminal so that it says something like this?

(env) PS C:UsersuserDocumentsCodeflaskTutorial>

Note: typing envScriptsactivate in cmd does activate it in cmd, but I would like to work in vscode.

2

Answers


  1. Have you tried only typing

    envScriptsactivate
    

    Venv in windows is a little tricky sometimes.

    Login or Signup to reply.
  2. The error message indicates that the execution of PowerShell scripts is disabled on your system, which is preventing the activation script from running in Visual Studio Code.

    You have to options: either change the Powershell Execution Policy or change the default terminal of VS Code to CMD.

    For the Default terminal option see VSCode Change Default Terminal

    • Open a PowerShell terminal with administrative privileges. To do this, right-click on the PowerShell icon and select "Run as administrator".

    • Run: Get-ExecutionPolicy

    • If the execution policy is set to "Restricted" or "AllSigned", it means that PowerShell is preventing the execution of scripts. To enable script execution, you can set the execution policy to "RemoteSigned" or "Unrestricted" (more permission, but higher risk). Run one of the following commands to set the execution policy:

    Run either Set-ExecutionPolicy RemoteSigned or Set-ExecutionPolicy Unrestricted.

    Accept the change by typing Y.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search