Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError in colab notebook #150

Open
amrzv opened this issue Aug 17, 2024 · 0 comments
Open

ImportError in colab notebook #150

amrzv opened this issue Aug 17, 2024 · 0 comments

Comments

@amrzv
Copy link

amrzv commented Aug 17, 2024

  • Contextualized Topic Models version: 2.5.0
  • Python version: 3.10.12
  • Operating System: Ubuntu 22.04.3 LTS

Hello.
On the line

from contextualized_topic_models.utils.preprocessing import WhiteSpacePreprocessingStopwords

the ImportError is raised

ImportError: cannot import name 'triu' from 'scipy.linalg.special_matrices' (/usr/local/lib/python3.10/dist-packages/scipy/linalg/special_matrices.py)

when running Combined TM on Wikipedia Data (Preproc+Saving+Viz) (stable v2.3.0) notebook in colab.

Full traceback

/usr/local/lib/python3.10/dist-packages/sentence_transformers/cross_encoder/CrossEncoder.py:11: TqdmExperimentalWarning: Using `tqdm.autonotebook.tqdm` in notebook mode. Use `tqdm.tqdm` instead to force console mode (e.g. in jupyter console)
  from tqdm.autonotebook import tqdm, trange
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[6], line 3
      1 from contextualized_topic_models.models.ctm import CombinedTM
      2 from contextualized_topic_models.utils.data_preparation import TopicModelDataPreparation
----> 3 from contextualized_topic_models.utils.preprocessing import WhiteSpacePreprocessingStopwords
      4 import nltk

File /usr/local/lib/python3.10/dist-packages/contextualized_topic_models/utils/preprocessing.py:4
      2 import string
      3 from nltk.corpus import stopwords as stop_words
----> 4 from gensim.utils import deaccent
      5 import warnings
      7 class WhiteSpacePreprocessing():

File /usr/local/lib/python3.10/dist-packages/gensim/__init__.py:11
      7 __version__ = '4.2.0'
      9 import logging
---> 11 from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
     14 logger = logging.getLogger('gensim')
     15 if not logger.handlers:  # To ensure reload() doesn't add another one

File /usr/local/lib/python3.10/dist-packages/gensim/corpora/__init__.py:6
      1 """
      2 This package contains implementations of various streaming corpus I/O format.
      3 """
      5 # bring corpus classes directly into package namespace, to save some typing
----> 6 from .indexedcorpus import IndexedCorpus  # noqa:F401 must appear before the other classes
      8 from .mmcorpus import MmCorpus  # noqa:F401
      9 from .bleicorpus import BleiCorpus  # noqa:F401

File /usr/local/lib/python3.10/dist-packages/gensim/corpora/indexedcorpus.py:14
     10 import logging
     12 import numpy
---> 14 from gensim import interfaces, utils
     16 logger = logging.getLogger(__name__)
     19 class IndexedCorpus(interfaces.CorpusABC):

File /usr/local/lib/python3.10/dist-packages/gensim/interfaces.py:19
      7 """Basic interfaces used across the whole Gensim package.
      8 
      9 These interfaces are used for building corpora, model transformation and similarity queries.
   (...)
     14 
     15 """
     17 import logging
---> 19 from gensim import utils, matutils
     22 logger = logging.getLogger(__name__)
     25 class CorpusABC(utils.SaveLoad):

File /usr/local/lib/python3.10/dist-packages/gensim/matutils.py:22
     20 import scipy.linalg
     21 from scipy.linalg.lapack import get_lapack_funcs
---> 22 from scipy.linalg.special_matrices import triu
     23 from scipy.special import psi  # gamma function utils
     26 logger = logging.getLogger(__name__)

ImportError: cannot import name 'triu' from 'scipy.linalg.special_matrices' (/usr/local/lib/python3.10/dist-packages/scipy/linalg/special_matrices.py)

Downgrading scipy should solve the issue:

pip install scipy==1.10.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant