Skip to content

Cannot import BERTopic: SAVE_STATE_WARNING #439

@ziqizhang

Description

@ziqizhang

Hi

I am having the same issue described here but I cannot solve the problem: #341

I can confirm that I have started from a fresh environment. I created a conda environment from scratch, using Python 3.6. I ran all the installation commands:

pip install bertopic
pip install bertopic[flair]
pip install bertopic[gensim]
pip install bertopic[spacy]
pip install bertopic[use]

And no errors were reported. However, when trying to import bertopic, I got the error below. I know that this is often due to incompatible torch and transformers being installed, but I already started from a fresh environment. My torch=1.10.1, transformers=3.5.1. I don't know where to look for information if these two are compatible and if not, what are the compatible versions I have to install?

Thanks

Traceback (most recent call last):
  File "/home/zz/Work/bertopic/python/main.py", line 1, in <module>
    from bertopic import BERTopic
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/bertopic/__init__.py", line 1, in <module>
    from bertopic._bertopic import BERTopic
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/bertopic/_bertopic.py", line 16, in <module>
    from sentence_transformers import SentenceTransformer
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/sentence_transformers/__init__.py", line 3, in <module>
    from .datasets import SentencesDataset, ParallelSentencesDataset
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/sentence_transformers/datasets/__init__.py", line 3, in <module>
    from .ParallelSentencesDataset import ParallelSentencesDataset
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/sentence_transformers/datasets/ParallelSentencesDataset.py", line 4, in <module>
    from .. import SentenceTransformer
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/sentence_transformers/SentenceTransformer.py", line 11, in <module>
    import transformers
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/transformers/__init__.py", line 626, in <module>
    from .trainer import Trainer
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/transformers/trainer.py", line 69, in <module>
    from .trainer_pt_utils import (
  File "/home/zz/Programs/anaconda3/envs/bertopic/lib/python3.6/site-packages/transformers/trainer_pt_utils.py", line 40, in <module>
    from torch.optim.lr_scheduler import SAVE_STATE_WARNING
ImportError: cannot import name 'SAVE_STATE_WARNING'

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions