ScaNN Library on Colab Imports correctly but fails on call with ImportError

I was able to successfully run pip install scann in my google colab notebook, but I am still getting an error when trying to use the tfrs.layers.factorized_top_k.ScaNN() function:

Looking in indexes:,
Collecting scann
  Downloading scann-1.2.7-cp37-cp37m-manylinux_2_27_x86_64.whl (11.2 MB)
     |████████████████████████████████| 11.2 MB 6.6 MB/s 
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from scann) (1.21.6)
Requirement already satisfied: six in /usr/local/lib/python3.7/dist-packages (from scann) (1.15.0)
Requirement already satisfied: tensorflow~=2.9.0 in /usr/local/lib/python3.7/dist-packages (from scann) (2.9.1)
Requirement already satisfied: oauthlib>=3.0.0 in /usr/local/lib/python3.7/dist-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.10,>=2.9->tensorflow~=2.9.0->scann) (3.2.0)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.7/dist-packages (from packaging->tensorflow~=2.9.0->scann) (3.0.9)
Installing collected packages: scann
Successfully installed scann-1.2.7

Output from scann = tfrs.layers.factorized_top_k.ScaNN(num_reordering_candidates=100, query_model=model._query_model):

ImportError                               Traceback (most recent call last)
<ipython-input-20-7c16542b601a> in <module>
----> 1 scann = tfrs.layers.factorized_top_k.ScaNN(num_reordering_candidates=100, query_model=model._query_model)
      2 # recommends movies out of the entire movies dataset.
      3 scann.index_from_dataset(
      4, items.batch(100).map(model._candidate_model)))
      5 )

/usr/local/lib/python3.7/dist-packages/tensorflow_recommenders/layers/ in __init__(self, query_model, k, distance_measure, num_leaves, num_leaves_to_search, training_iterations, dimensions_per_block, num_reordering_candidates, parallelize_batch_searches, name)
    655     if not _HAVE_SCANN:
    656       raise ImportError(
--> 657           "The scann library is not present. Please install it using "
    658           "`pip install scann` to use the ScaNN layer.")

ImportError: The scann library is not present. Please install it using `pip install scann` to use the ScaNN layer.

I must be missing something simple. Help.

In order to expedite the trouble-shooting process, please provide a code snippet to reproduce the issue reported here. Thank you.

1 Like

@chunduriv Thanks for responding. I re-ran the tests this morning with the identical Colab notebook and it runs without errors. I imagine this was a temporary failure and it is now resolved.