brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pip only-binary stops pip from building packages from source

Pip
~/tips/tip-pip-only-binary-all

python3 -m pip install --only-binary=:all: numpy

Fail fast instead of compiling when no prebuilt wheel exists.

You install one package and suddenly a compiler is running, pages of output scroll by, and it ends in an error about a missing header file. pip found no ready made wheel for your system and tried to build from source.

You can forbid that:

python3 -m pip install --only-binary=:all: numpy

Now pip only considers wheels. If the newest release has none for your Python and platform, it may pick an older one that does, and if there is nothing at all you get a short “no matching distribution” error. I would take that over ten minutes of compiling that ends the same way.

Instead of :all: you can name packages, separated by commas:

python3 -m pip install --only-binary=numpy,pillow -r requirements.txt

It’s also a small safety net, since building from source runs code from the package on your machine during the install.

Not everything publishes wheels. Some small packages ship only a source archive and will now fail even though building them would have been painless. Name the troublesome packages in that case. And if pip quietly settles on an old version, check which one got installed before you trust it.

Further reading: pip install

More Pip tips urllib3<2 python3 -m pip download -r requirements.txt -d ./wheels python3 -m pip config set global.timeout 60 python3 -m pip index versions requests python3 -m pip download requests==X.Y.Z --no-deps -d ./pkgs All Pip tips (9) All topics

Link