13

I want to run the Windows (Command Prompt) equivalent of

source myvenv/bin/activate

so as to activate and enter into my virtual environment.

blank_mind
  • 217
  • 1
  • 2
  • 7

5 Answers5

7

At CMD prompt,it worked by running

myvenv\scripts\activate.bat
Dave M
  • 13,138
  • 25
  • 36
  • 47
blank_mind
  • 217
  • 1
  • 2
  • 7
  • Given this self-answer, the asker appears to be using [vanilla Python](https://www.python.org) and virtual environments created with `python -m venv some-environment` (rather than, say, using `conda`). – Anaksunaman May 24 '18 at 20:15
  • Specific to your question "What is the alternative for source command in cmd?" The equivalent command to "source" is "call".. but it is only used from another batch file. – Señor CMasMas May 14 '19 at 16:01
  • 1
    "The system cannot find the path specified." - not helpful. – Sean Kendle Aug 11 '22 at 21:55
4

For activating an environment:

activate myenv

for deactivating (all)

deactivate
MarianD
  • 2,666
  • 1
  • 17
  • 26
3

Go to the the directory where you have the ".bat" file by executing this command:

C:\Users\MyName\Desktop\ProjectsWork\FlaskApplication> cd env\Scripts

Then just call the ".bat" file

\Desktop\ProjectsWork\FlaskApplication\env\Scripts> activate.bat

(env) C:\Users\MyName\Desktop\ProjectsWork\FlaskApplication\env\Scripts>

Mourad
  • 139
  • 1
0

If you want to activate your virtual environment after running:

virtualenv env  

Just run:

env\Scripts\activate

This command will provide you the correct path and the command "source" is not necessary.

Example Image

Kevin Horn
  • 138
  • 5
Karen
  • 9
  • 1
0

If you want to use your environment in batch file then

call C:\ProgramData\Anaconda3\Scripts\activate.bat C:\ProgramData\Anaconda3

All the following command will be executed in virtual environment

Qin Heyang
  • 321
  • 2
  • 3
  • 8