Virtual environment error: "The term 'source' is not recognized as the name of a cmdlet ..."

231 views Asked by At

I have successfully created a virtual environment (using venv), but I get an error when trying to activate it.

PS C:\Users\...> python -m venv projects
PS C:\Users\...> source venv/bin/activate
source : The term 'source' 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
+ source venv/bin/activate
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (source:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

terminal output

Why do I get this error, and how do I fix it?

1

There are 1 answers

0
Gaberocksall On BEST ANSWER

There are two issues:

  1. You have created a virtual environment named projects (here: python -m venv *projects*), but you're trying to activate an environment named venv (here: source *venv*/bin/activate).
  2. source is not a powershell command - you cannot use it. Instead, use the powershell script that venv provides: .\projects\Scripts\activate