virtualenv activate does not work

Viewed 24412

I am trying to create a virtual environment to test an api.

I can create the environment just fine using virtualenv test, then I can cd into it. When I try to run activate, I get this error:

PS C:\Users\Bright Bridge\Desktop\autocomplete_demo\Scripts> activate
activate : The term 'activate' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ activate
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (activate:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Suggestion [3,General]: The command activate was not found, but does exist in the current location. Windows PowerShell does not load commands from the current
 location by default. If you trust this command, instead type: ".\activate". See "get-help about_Command_Precedence" for more details.

I recently updated windows, and it replaced the cmd with Windows Powershell. My virtualenv worked fine with the cmd, so I suspect it may have to do with the way the Powershell does things.

How can I activate the virtualenv?

11 Answers

For those of you still interested, the output gives you the answer:

If you trust this command, instead type: ".\activate".

So use a relative path name to run the activate script in powershell, or use an absolute path

You need to set windows execution policies. According to official documentation of virtualenv.

Run in powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUse

Now you can activate virtual env. using \Scripts\Activate.ps1

Hope it solves it!

Just Enter one PowerShell Command

  1. .\Scripts\activate

    Rather Then

  2. ./Scripts/activate

Execute .\activate instead of activate

That worked for me.

You basically needs to set execution policy for PowerShell

Step 1: Run PowerShell as Administartor

Step 2: Run Below Command

Set-ExecutionPolicy RemoteSigned

After successfull run, You will be able to activate vertual environemnt.

Enjoy :)

Use command pompt instead of using power-shell and run the same command

enter image description here

this should work

after jumping to Scripts folder cd Scripts just write .\activate It works perfectly

Instead of all variants it works with C:...venv\scripts .\activate.ps1 But before that, I changed my ExecutionPolicy to RemoteSigned. You can do it by next steps.

  1. Enter Set-ExecutionPolicy
  2. Enter RemoteSigned
  3. System should ask you if u wish to save changes. Answer with "Y" enter image description here

1.Just add the complete path in cmd like this " cd.\pyenvDjango\Scripts" and press enter,

  1. Now you see the complete directory path in which you are.

  2. Now just type ".\activate".

  3. this will activate your env.

NOTE:- try this in cmd not in vs code terminal or any where

Related