Reputation: 11
I want to distribute a python script with external requirements, but I don't want to clutter up the users machines. Can I my script activate a virtual environment, and install its requirements to said VE.
Additionally, is there a way to have the VE destroy itself once the script in finished executing.
Upvotes: 1
Views: 1224
Reputation: 44118
You do not need to explicitly activate the virtual environment. If the virtual environment is located at /path-to-venv
, then executing:
/path-to-venv/bin/pip install package
will install package
into the virtual environment. Likewise, running the Python interpreter located at /path-to-venv/bin/python
will cause packages to be loaded from the virtual environment located at /path-to-venv
without the need for an explicit activation.
Upvotes: 1