0

I am trying to set up a virtual env in my VS code, but can't activate virtual env. The command is not working, although when I am using the same command in Pycharm it's working

below is the error that I'm getting:

VS code Virtual env not activating

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
  • Don't post images, copy-paste the error here directly. Also there is an error message, have you tried looking up what it means and how to make it work with vscode? – ShadowMitia Nov 02 '21 at 12:00
  • 2
    Does this answer your question? ['virtualenv' won't activate on Windows](https://stackoverflow.com/questions/18713086/virtualenv-wont-activate-on-windows) – unityJarvis Nov 02 '21 at 12:08
  • In case the Powershell policy is not working for you, please try and set command prompt (cmd) as the default shell in vs code. This issue is not present in cmd – unityJarvis Nov 02 '21 at 12:10
  • 2
    Welcome to Stack Overflow. Please edit the question to include any necessary source code, data, and error messages as text. Consider [these reasons and guidelines](https://meta.stackoverflow.com/a/285557). – bad_coder Nov 02 '21 at 12:48

2 Answers2

1

You need to change the terminal type to Command Prompt: enter image description here

Karol Żak
  • 2,158
  • 20
  • 24
0

According to Microsoft Tech Support it might be a problem with Execution Policy Settings. To fix it, you should try executing Set-ExecutionPolicy Unrestricted -Scope Process (as mentioned in the comment section by @wtsiamruk) in your PowerShell window. This would allow running virtualenv in the current PowerShell session.

There is also another approach that is more unsafe, but recommended by MS Tech Support. This approach would be to use Set-ExecutionPolicy Unrestricted -Force (which do unleash powers to screw Your system up). However, before you use this unsafe way, be sure to check what your current ExecutionPolicy setting is by using get-ExecutionPolicy. Then, when you are done, you can revert back to this ExecutionPolicy by using Set-ExecutionPolicy %the value the get-ExecutionPolicy command gave you% -Force.

Quoted from here.

Onur
  • 164
  • 1
  • 18