r/pythontips • u/cdman • Aug 04 '16
Run scripts in virtualenvs without activating them first
If you have a virtualenv in env for example and you want to run a script from it (youtube-dl for example), usually you would activate it and then run it:
source env/bin/activate
youtube-dl ...
However you can run it directly without needing to activate the virtualenv first!
./env/bin/youtube-dl ...
This works for everything from the virtualenv (for example ./env/bin/pip ... to install something into the given env without activating it) and you can run arbitrary python scripts using the env python like this: ./env/bin/python myscript.py
30
Upvotes
1
u/[deleted] Aug 04 '16
Neat... TIL