I'm attempting to automate some of the steps I routinely go through in setting up venv
environments in Python. I'm able to get to where I create the folder and a requirements.txt
folder inside, containing any modules I desire. But it seems like the session doesn't remember the last command, preventing me from activating the venv
and installing the requirements.txt
file afterwards.
# Navigate to new venv directory
subprocess.run("cd " + destination, shell=True)
# Activate venv environment.
subprocess.run("Scripts\\activate.bat", shell=True)
# Install requirements with pip.
subprocess.run("pip install -r requirements.txt", shell=True)
Output:
The system cannot find the path specified.
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'