How to enable Virtualenv in Windows command prompt?

Asked

Viewed 59 times

-2

On Linux I can run

. bin/activate

I tried the same command on Windows, but it didn’t work. How do I activate virtualenv on Windows?

1 answer

3

When you create Virtualenv from Windows, the created folder structure will be:

D:\projeto\venv
│   pyvenv.cfg
│
├───Include
│       ...
├───Lib
|       ...
└───Scripts
        activate
        activate.bat
        Activate.ps1
        deactivate.bat
        easy_install-3.9.exe
        easy_install.exe
        pip.exe
        pip3.9.exe
        pip3.exe
        python.exe
        pythonw.exe

That is, the path you tried to run, bin/activate, will not exist. Even if it existed it would not work, as this file has instructions for configuring Linux environments.

On Windows, you can use the file activate.bat or the activate.ps1 if you are using Powershell.

Example:

D:\projeto> .\venv\Scripts\activate.ps1
(venv) D:\projeto>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.