Installing Hy with uv
Published:
In the past I would have used good ol' pip. Today I used uv. Python's package management keeps being what it is, but this is not the point of this post.
I wanted to have hy as a regular program installed in my
~/.local/bin and available everywhere, not only in a particular
virtualenv.
In the year 2026 there are several wrong ways to go about it.
pip3 install hy
error: externally-managed-environment
The above clearly does not work, because I am trying to install the package
as a user into a system-wide directory.
Let's try doing "the right thing" with the --user flag.
pip3 install --user hy
error: externally-managed-environment
This is not really Python's fault—it only obeys the system configuration
here.
However, this error message stems from the fragility that has for a long
time plagued Python's package management.
The error message helpfully suggests using the
--break-system-packages flag if you believe this is not a real
error.
pip3 install --break-system-packages hy
Running pip with --break-system-packages would work, but you
need to ask yourself a simple question: do I want to live my life running
commands with flags named suspiciously close to --fuck-me-up?
I would rather not.
Seeing how the built-in, recommended tool is failing, let's turn to the (at the time of writing) newish, released in early 2024, kid on the block ie, uv:
uv tool install hy
It worked.
hy
Hy 1.3.1 (Eyes in the Sky) using CPython(main) 3.14.7 on Linux
=> (print "Hello, World!")
Hello, World!
It worked well.
I think this only highlights the importance of shipping a well thought out package manager with your programming language, if you are shipping one. OCaml and Rust succeeded. Python failed. Java failed. C++ did not even try.
Given the fact that uv is written in Rust, I guess Rust is winning so much that the spoils of victory are spilling over to Python.
Controversial use-case?
It seems that the simple use-case of installing a tool to a user's home
directory is a bit of a contentious issue.
Since uv was supposed to be a drop-in replacement for pip, it has a
pip subcommand.
However, there subcommand does not support the full feature set of pip;
and some features
will never be
supported—for example the --user flag:
uv pip install --user foo
To quote the developers: "we do not allow installation outside of a virtual environment right now". Another similar request has also been closed as not planned.
The uv tool install is there for site-wide installations
and works, though, so I've got that going for me.
Which is nice.
Previous: A concerning lack of vitality of VitalSource ebooks