MaartenGr / MaartenGr/BERTopic

Incompatibility with Python 3.12.1 on Linux

Open
#2,091 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
7.8k
Forks
920
Avg merge
22h 24m
Merged PRs (30d)
5

Description

Have you searched existing issues? 🔎
  • I have searched and found no existing issues
Desribe the bug

Import works fine when I roll back to Python 3.9.0. Get the following error on 3.12.1. On CentOS.

System info:
CentOS Linux release 7.9.2009 (Core) NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora"

Error:
/home/users/$USER/.local/lib/python3.12/site-packages/hdbscan/plots.py:448: SyntaxWarning: invalid escape sequence '\l' axis.set_ylabel('$\lambda$ value') /home/users/$USER/.local/lib/python3.12/site-packages/hdbscan/robust_single_linkage_.py:154: SyntaxWarning: invalid escape sequence '\{' """Perform robust single linkage clustering from a vector array Traceback (most recent call last): File "/home/groups/$USER/fd_export/extract_body.py", line 4, in <module> from bertopic import BERTopic File "/home/users/$USER/.local/lib/python3.12/site-packages/bertopic/__init__.py", line 1, in <module> from bertopic._bertopic import BERTopic File "/home/users/$USER/.local/lib/python3.12/site-packages/bertopic/_bertopic.py", line 59, in <module> import bertopic._save_utils as save_utils File "/home/users/$USER/.local/lib/python3.12/site-packages/bertopic/_save_utils.py", line 29, in <module> import torch File "/home/users/$USER/.local/lib/python3.12/site-packages/torch/__init__.py", line 562, in <module> for name in dir(_C): ^^ NameError: name '_C' is not defined

Reproduction
from bertopic import BERTopic
BERTopic Version

0.16.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the import from the issue with Python 3.12.1 on CentOS 7 and inspect the traceback through bertopic/_save_utils.py into torch/init.py. Compare the failing environment with Python 3.9.0 and verify that importing BERTopic completes without the reported _C NameError.

Written by the indexing model from the issue text.

Assessment

Tech stack
centos, python, pytorch
Domain
machine-learning, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.