venv
我正在尝试自动化我在 Python中设置环境时经常执行的一些步骤。我能够到达创建文件夹的位置和其中的requirements.txt
文件夹,其中包含我想要的任何模块。但似乎会话不记得最后一个命令,阻止我之后激活venv
和安装requirements.txt
文件。
# 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)
输出:
The system cannot find the path specified.
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'