7

I'd like to specify the versions of tensorflow in a Python module. The agreeable versions are:

(version >= 1.14.0 and version < 2.0) or (version >= 2.2)

Does anyone know how to express this strange situation in a requirements.txt file? I believe there's a syntax for forbidding specific versions of a module, but I haven't been able to find it...

duhaime
  • 25,611
  • 17
  • 169
  • 224

1 Answers1

10

From PEP 440 Version Specifiers:

tensorflow >=1.14.0,!=2.0.*,!= 2.1.*

The comma , represents a logical and.

Note that requirements.txt files are used for pinning a deployment, I would generally only expect to ever see == specifiers used in those files.

wim
  • 338,267
  • 99
  • 616
  • 750
  • Also interesting: [What does tilde equals ~= mean?](https://stackoverflow.com/q/39590187/1016343) It is a good way to allow minor updates, but not breaking major updates. In some situations, it can be better than `==`. – Matt Nov 11 '22 at 12:45