2

Picture of the virtual environment working in Command Prompt, and not working in Powershell with the error I've been trying to get this virtual environment to work with powershell, but I keep getting this error. The virtual environment works in Command Prompt, but not in Powershell, so I've been wondering what I can do to fix that.

1
  • 2
    Please (also) post your code, data, error messages as text, not (just) as images. Commented Jul 12, 2021 at 20:52

3 Answers 3

4

There are three (3) "activate" scripts in the venv scripts directory.

PS C:\venv\py39\Scripts> (Get-ChildItem -Filter 'act*').Name
activate
activate.bat
Activate.ps1

These are used in the following shells.

activate        # bash
activate.bat    # cmd.exe
Activate.ps1    # powershell.exe or pwsh.exe

Use the following for PowerShell.

.\Activate.ps1

The Activate.ps1 script includes a deactivate function. Therefore, no deactivate.ps1 script is needed.

Sign up to request clarification or add additional context in comments.

Comments

1

Primary issue is that PowerShell - as you can see on your screenshot - doesn't load commands from the current location by default. Just as it suggests you, try to use .\activate instead of activate.

But that also might not help and lead to other issue connected to the Execution Policies. The command throws some security exceptions after trying to activate the virtual environment. And as it is completly different thing and in order to not duplicate answers, I will redirect you to this thread which should help you with that.

Comments

0

Sometimes I have gotten that error, instead of activate, try .\activate.ps1

1 Comment

Good point, but it isn't just sometimes: In order to execute a script located in the current directory, PowerShell always requires you to explicitly prefix the script name with .\ (or ./).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.