-2

I want install virtualenv. I type

pip install virtualenv

and the response is

Requirement already satisfied: virtualenv in c:\users\novin\appdata\roaming\python\python38\site-packages (20.6.0)
Requirement already satisfied: platformdirs<3,>=2 in c:\users\novin\appdata\roaming\python\python38\site-packages (from virtualenv) (2.2.0)
Requirement already satisfied: distlib<1,>=0.3.1 in c:\users\novin\appdata\roaming\python\python38\site-packages (from virtualenv) (0.3.2)
Requirement already satisfied: filelock<4,>=3.0.0 in c:\programdata\anaconda3\lib\site-packages (from virtualenv) (3.0.12)
Requirement already satisfied: backports.entry-points-selectable>=1.0.4 in c:\users\novin\appdata\roaming\python\python38\site-packages (from virtualenv) (1.1.0)
Requirement already satisfied: six<2,>=1.9.0 in c:\programdata\anaconda3\lib\site-packages (from virtualenv) (1.15.0)

And when I want active it, type it "source bin/activate", and the response is "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 bin/activate
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (source:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException"
Lukr
  • 659
  • 3
  • 14
  • Shouldn't you need to create a virtual environment directory first using command `virtualenv ` and then you can activate it using `source /bin/activate`? – tax evader Aug 01 '21 at 13:54
  • What operating system are you using? – 9769953 Aug 01 '21 at 14:01
  • `source` doesn't work in PowerShell; that is for linux/unix/macos and the like. – 9769953 Aug 01 '21 at 14:03
  • https://stackoverflow.com/search?q=%5Bvirtualenv%5D+The+term+source+is+not+recognized+as+the+name+of+a+cmdlet%2C+function%2C+script+file%2C+or+operable+program.+Check+the+spelling+of+the+name%2C+or+if+a+path+was – phd Aug 01 '21 at 15:32

1 Answers1

1

First, make a venv:

C:\Users\username> mkvirtualenv web

A quick workaround would be to activate cmd like this:

PS C:\Users\username> cmd
Microsoft Windows [Version 10.0.19043.1151]
(c) Microsoft Corporation. All rights reserved.

C:\Users\username>workon web
(web) C:\Users\username>

If you insist on working in PowerShell, run:

PS C:\Users\username> .\\Envs\web\Scripts\activate.ps1

Here, Envs is the directory in which your venvs are stored, for me the directory is : C:\Users\username\Envs

But, to use this, you have to Run PowerShell as an Administrator, after that, run:

PS C:\Users\username> Set-ExecutionPolicy Unrestricted

After this you will be able to run your virtual environment.

Theorist
  • 159
  • 1
  • 8