For larger Python packages which might interfere with other packages it is recommended to install them into their own virtual environment and some Python packages expose CLI commands to the shell.
Is there a way to pip-install such a package into its own virtual environment, but have the CLI commands accessible from a normal shell without switching beforehand manually to this virtual environment?
Here an example: When I install csvkit via
pip install csvkit
I have the commands csvcut
, csvlook
, csvgrep
and others available in my
shell. However if I do not want to install cvskit in my System-Python and
install it in a virtual environment, say at ~/venvs/csvkit
, I have
csvkit only available if I have manually activated the environment
csvkit
.
Is there a way to create the virtual environment and install csvkit in it,
so that the commands like csvcut
activate the environment themselves before
they run?
A newer tool which still is very well maintained is pipx - Install and Run Python Applications in Isolated Environments. It works similar to pipsi:
pipx
. (See pipx installation)Then issue:
pipx install csvkit
Finally make sure pipx
's bin directory (normally ~/.local/bin
) is in your PATH.
Please note, pipx has additional commands for maintaining and inspecting of the generated venvs - see pipx --help
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With