Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pyenv, how can I pip install global CLIs and make them available even when in a virtualenv?

Tags:

python

pip

pyenv

There are many pip-installed CLI's like ansible and black that I want to have access to always, no matter which python version or virtualenv I am using. If I mark a certain python installation as global (a la pyenv global 3.10.0), I can then use pip to install these CLI's into that global python's site-packages, and pyenv makes them runnable while I'm using the global python. However, they become unavailable once I'm inside a virtualenv. This makes me no longer able to use tools for linting, deploying, and doing generic system-related tasks without installing these tools into the virtualenv, which I do not want to do.

Is there a supported or common way of solving this problem so that I can install certain pip packages which include binaries, and have those binaries always accessible?

like image 854
Christopher Shroba Avatar asked Oct 23 '25 11:10

Christopher Shroba


1 Answers

The Python Packaging Authority has a tool called PipX which is meant for exactly this purpose, check it out!

From the readme:

Overview: What is pipx?

pipx is a tool to help you install and run end-user applications written in Python. It's roughly similar to macOS's brew, JavaScript's npx, and Linux's apt.

It's closely related to pip. In fact, it uses pip, but is focused on installing and managing Python packages that can be run from the command line directly as applications.

like image 76
tzaman Avatar answered Oct 24 '25 23:10

tzaman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!