How pip reads each operator
These rows are checked by the same code that powers the tool above. "Matches" means the version is inside the range. Pre-release filtering is a separate step, covered below.
| Specifier | Matches | Does not match |
|---|---|---|
==1.4.2 | 1.4.2, 1.4.2.0, 1.4.2+cpu | 1.4.3, 1.4.2.post1 |
==1.4.* | 1.4, 1.4.9, 1.4.9rc1 | 1.5, 1.40 |
!=1.5.* | 1.4.9, 1.6 | 1.5, 1.5.3 |
~=1.4.2 | 1.4.2, 1.4.10 | 1.4.1, 1.5 |
~=1.4 | 1.4, 1.9 | 1.3, 2.0 |
>1.4 | 1.4.1, 1.5 | 1.4.post1, 1.4+local |
<1.5 | 1.4.9 | 1.5rc1, 1.5.dev0 |
>=1.4 | 1.4, 2.0 | 1.3.9 |
<=1.4 | 1.4, 1.4+local | 1.4.1 |
~=is the compatible release operator:~=1.4.2means>=1.4.2, ==1.4.*. It needs at least two numbers, so~=1is invalid.>Vskips post-releases and local builds of V itself, and<Vskips pre-releases of V. So<2.0never selects2.0rc1, even with--pre.===compares raw strings and is meant as a last resort for versions that are not PEP 440 compliant.
When pip installs pre-releases
pip skips alpha, beta, release-candidate and dev versions (2.0a1, 2.0b3, 2.0rc1,
2.0.dev4) unless one of these is true:
- the specifier itself names a pre-release, as in
>=2.0rc1; - you pass
--pre(the checkbox above); - no final release satisfies the specifier. A project with only
1.0b1published still installs.
Common mistakes
~=1.0allows everything below 2.0, not just 1.0.x. Use~=1.0.0to stay on 1.0.x.=1.0,=>1.0,^1.0and~1.0are not PEP 440 operators.^and~are Poetry-only syntax.- Separate specifiers with commas:
>=1.0, <2.0. - Wildcards only work with
==and!=.>=1.0.*is invalid. - Spelling doesn't matter:
1.0-RC1,1.0.rc1and1.0rc1are the same version, and so are1.0and1.0.0.
About this checker
The matching engine is a TypeScript port of packaging 26.3, the library pip uses. It is tested against results produced by the real library for 65 specifiers × 65 versions, including invalid inputs and pre-release selection. Everything runs in your browser.