How to install a python package into an Virtual Environment without activating it?

Question:

Is it possible to install a python package into a virtual environment without activating it?
Imagine you just wish to update a virtual environment without activating it and install the package in it.

Asked By: Max

||

Answers:

You can use python from a virtual environment without activating the environment. For example if a virtual environment was created at /some/path/to/venv use /some/path/to/venv/bin/python — the program notices it’s in a virtual environment and acts as if the environment is activated. To install a package run

/some/path/to/venv/bin/python -m pip install -U package_name
Answered By: phd
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.