2

What is the difference between >= and ~= when use in python requirements.txt for some library? For example requests >= 2.18.0 and requests ~= 2.18.0

I have tried both the things and its working fine

requests >= 2.18.0
requests ~= 2.18.0

Could anyone please explain me the exact difference between the >= and ~= operator?

damon
  • 14,485
  • 14
  • 56
  • 75
Goutam
  • 839
  • 1
  • 7
  • 9

1 Answers1

6

To install greater than or equal to one version and less than another (ordered comparisons):

pip install 'SomeProject>=1,<2'

To install a version that’s compatible with a certain version (compatible releases):

pip install 'SomeProject~=1.4.2'

Both format specifiers are documented in PEP 440 – Version Identification and Dependency Specification.

damon
  • 14,485
  • 14
  • 56
  • 75
shaik moeed
  • 5,300
  • 1
  • 18
  • 54