Tags: #python #cli #flag
Install package using pip that’s associated with the currently running Python interpreter:
python3 -m pip install -e rig
Create simple virtual environments for the currently running Python interpreter using venv
:
# create the virtual environment
python3 -m venv /path/to/new/virtual/environment
# activate the virtual environment
source /path/to/new/virtual/environment/bin/activate
For a great breakdown of virtual environments and how they work, read: https://spurin.com/2019/03/12/Python-Virtual-Environments/. In short, the activate
command simply prefixes /path/to/new/virtual/environment/bin
to your $PATH
environment variable so it’ll look there for pip
and for installing/importing modules.
Note: subset was built into Python 3.3+ as
venv
module, otherwise use virtualenv.pypa.io for more features.
Use existing Python packages with -m
to do processing, like JSON formatting:
curl -sL http://j.mp/1IuxaLD | python -m json.tool
See also: http://pythonwise.blogspot.com/2015/01/python-m.html