0

I am using Google Colab and trying to use PyLDAvis to visualize a topic modelling model made from gensim. The python code was working fine but has suddenly started to give me the error:

ImportError: cannot import name '_NUMEXPR_INSTALLED' from 'pandas.core.computation.check' (/usr/local/lib/python3.7/dist-packages/pandas/core/computation/check.py)

The error comes from the line from pandas.core.computation.check import NUMEXPR_INSTALLED in the file /usr/local/lib/python3.7/dist-packages/pandas/core/computation/eval.py. I believe this line is being called by pyLDAvis.gensim_models.prepare.

I tried putting !pip install numexpr but it doesn't get rid of the error. What is surprising is that when I call !pip install numexpr, the output is:

Requirement already satisfied: numexpr in /usr/local/lib/python3.7/dist-packages (2.7.3)
Requirement already satisfied: numpy>=1.7 in /usr/local/lib/python3.7/dist-packages (from numexpr) (1.20.2)

which means that numexpr can be found in /usr/local/lib/python3.7/dist-packages

6
  • The current version of pandas has NUMEXPR_INSTALLED, but not _NUMEXPR_INSTALLED. Can you double-check your "eval.py" and "check.py" and make sure they match? Commented May 5, 2021 at 21:39
  • You may need to upgrade pandas in Colab. PyLDAvis requires >= 1.2, while Colab's installed version is 1.1.5. So try !pip install --upgrade pandas. Commented May 5, 2021 at 21:40
  • @TimRoberts any idea how to do that in Google Colab? Commented May 5, 2021 at 22:02
  • @AlexK that didn't work Commented May 5, 2021 at 22:02
  • 1
    @AvinashKumar in response to your question to @TimRoberts, in Colab you can use Unix commands to work with files: !cat /usr/local/lib/python3.7/dist-packages/pandas/core/computation/check.py will print the contents of check.py. Commented May 5, 2021 at 22:47

1 Answer 1

1

@AlexK's answer worked for me. I just had to specify which version of pandas to use in order for Colab to actually upgrade with:

!pip install --upgrade pandas==1.2
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.