7

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

source myvenv/bin/activate

so as to activate and enter into my virtual environment.

3
  • Batch file can automate what you want, but you need to know what activate does, and translate it accordingly. – Darius May 23 '18 at 11:30
  • Well I do not have any idea how to do this :/ – blank_mind May 23 '18 at 11:32
  • If you have solved the problem, please post your answer as an answer in the “Your Answer” box (below). – Scott May 23 '18 at 19:01
5

At CMD prompt,it worked by running

myvenv\scripts\activate.bat
2
  • Given this self-answer, the asker appears to be using vanilla Python 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
3

For activating an environment:

activate myenv

for deactivating (all)

deactivate
2
  • not working says 'activate' not a recognized command – blank_mind May 23 '18 at 11:35
  • Did you used conda for creating your environments? Try the command conda from your cmd window. – MarianD May 23 '18 at 11:50
1

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

0

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>

0

In windows you don't need any command to activate an environment.

source myvenv/bin/activate

Image for demonstration and example:

enter image description here

just use:

myvenv/bin/activate

Image for demonstration and example:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.