Skip to content

Commit fbb880f

Browse files
Johannes BalléSung Jin Hwang
authored andcommitted
Adds error message for missing TF dependency.
PiperOrigin-RevId: 258625168 Change-Id: I1112a934ed30a1a212f0c78f22aa9bd2782540e1
1 parent ca624db commit fbb880f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ py_binary(
3535
"//tensorflow_compression/python/layers:py_src",
3636
"//tensorflow_compression/python/ops:py_src",
3737
],
38+
python_version = "PY3",
3839
)
3940

4041
py_binary(

tensorflow_compression/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
from __future__ import division as _division
1919
from __future__ import print_function as _print_function
2020

21+
try:
22+
import tensorflow as _tensorflow
23+
_tf_version = [int(v) for v in _tensorflow.version.VERSION.split(".")]
24+
assert _tf_version[0] == 1 and _tf_version[1] >= 14
25+
except (ImportError, AssertionError):
26+
raise RuntimeError("For tensorflow_compression, please install TensorFlow "
27+
"1.14 or above. TensorFlow 2 is not yet supported.")
28+
29+
2130
# pylint: disable=wildcard-import
2231
from tensorflow_compression.python.layers.entropy_models import *
2332
from tensorflow_compression.python.layers.gdn import *

0 commit comments

Comments
 (0)