I'm a strong pyenv
and Poetry user that's beginning to use pipx
and looking to learn more about how it works. Specifically, I'd like to understand how it determines which Python version to use when installing.
I've noticed that it seems to search PATH
for existing references to applications when you pipx install <package>
to make existing installations accessible globally. This, for instance, works well with pyenv
where it pipx
will find a version of the package you install across any Python versions installed via pyenv
.
pipx install cookiecutter
â ď¸ Note: cookiecutter was already on your PATH at ~/.pyenv/shims/cookiecutter
installed package cookiecutter 1.7.3, Python 3.9.6
These apps are now globally available
- cookiecutter
done! ⨠đ â¨
But what if it's a package you've never installed before? And there's a package version compatible with 3.6, 3.7, and 3.8 â how will it determine with Python version to use when installing this package?
I've found you can provide the Python version PipX should install the package into by providing it as an argument to the install
command (see below).
More specifically, when using pyenv
, you can switch to the version you desire to install into and then provide $(which python)
to automatically provide the path to that Python version...
pyenv shell 3.X.X
pipx install <package-name> --python $(which python)
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