David Nan
David Nan

Reputation: 11

Is there a way to run pip inside a virtual environment from a python script?

python_bin = 'venv\Scripts\python.exe'
subprocess.run([python_bin, 'pip', 'install', '-r', 'requirements.txt'])

This is what I am trying to do but it doesn't recognize pip

Upvotes: 1

Views: 230

Answers (1)

Sören
Sören

Reputation: 2456

You're missing the -m:

subprocess.run([python_bin, '-m', 'pip', 'install', '-r', 'requirements.txt'])

Upvotes: 2

Related Questions