Home > Back-end >  batch command inside python virtual env
batch command inside python virtual env

Time:08-21

I have a .bat script that does

cd documents/code/project
env/scripts/activate.bat

but one is there, as expected, the path is not

C:\Users\User\Documents\Code\Project>

but

(env) C:\Users\User\Documents\Code\Project>

So, for example, if I add other command to the batch script it won't get it because the virtual environment is not accessible

let's supose I just want to change directory but with the environment already active. i.e.

cd documents/code/project
env/scripts/activate.bat
cd folderInProject

How can I do it?

Thanks

CodePudding user response:

Thanks @Compo, @MattDMo for your comments, they opened my mind a lot and I'll have to study.

The solution is:

CD "documents\code\project"
Call "env\scripts\activate.bat"
CD "src"

but actually what I was looking was:

CD "documents\code\project"
Call "env\scripts\activate.bat"
Call python test.py

Just wanted to know how to be able to send batch commands once the env was already active.

  • Related