Public bug reported:

Given the test code junk.py:

from bs4 import BeautifulSoup
if __name__ == "__main__":
    print ("test")

I get a stacktrace on doing "python3 junk.py"

After doing sudo apt-get install python3-bs4
python3 junk.py
Traceback (most recent call last):
  File "/home/davea/misc/kb2db/junk.py", line 2, in <module>
    from bs4 import BeautifulSoup
  File "/usr/lib/python3/dist-packages/bs4/__init__.py", line 29, in <module>
    import traceback
  File "/usr/lib/python3.12/traceback.py", line 5, in <module>
    import linecache
  File "/usr/lib/python3.12/linecache.py", line 11, in <module>
    import tokenize
  File "/home/davea/misc/kb2db/tokenize.py", line 65, in <module>
    from bs4 import BeautifulSoup
ImportError: cannot import name 'BeautifulSoup' from partially initialized 
module 'bs4' (most likely due to a circular import) 
(/usr/lib/python3/dist-packages/bs4/__init__.py). Did you mean: 
'BeautifulStoneSoup'?

I could well be the only person with this problem.

If something is truly partially initialized I have no idea how to find
it.

'pip3 list' shows beautifulsoup4

ls -a shows

.                  dumpscript             photos
..                 emailsfrom124899.mbox  __pycache__
addfile.py         europautf.mbox         pysearch2023
all-emails-so-far  getdaemonlog           readmbox.py
apache2-bottle     .git                   README
BKUPTOTAR          images.py              runtoken.sh
yyybs4             jjcontents             scanlog.py
bs4problem         junkfill               setupvenv.sh
BUILDNEWDB         junk.py                singlemail.py
buildsqlite.py     kbhtm.py               snaplocalmailbox.txt
checkdate.py       knowledgebase.txt      splitlong.py
CLEANUP            lotuseuropambox        tokenize.py
datesorting.py     lotuseuropambox.2      venvnltk
dbsize.txt         MAKEJSON.sh            webcode
deblankname.py     messageaverage.py      yah_to_utf.py
digtombx.py        modulesdoc

I expect this is all my fault because bs4 beautifulsoup4 was working. 
and it stopped working maybe I corrupted something? Somehow? Where?

Description:    Ubuntu 24.04.3 LTS
Release:        24.04

After sudo apt purge python3-bs4 I put the bs4 source dir into the project
so the import would use that up to date from a tarball from the maintainer of
bs4.
Typing  'python3 junk.py'
Exactly the same error arises!

Without any bs4 or beautifulsoup4 visible or installed the test code fails
as it finds no bs4. That is perfectly reasonable.

ProblemType: Bug
DistroRelease: Ubuntu 24.04
Package: python3-bs4 (not installed)
ProcVersionSignature: Ubuntu 6.8.0-90.91-generic 6.8.12
Uname: Linux 6.8.0-90-generic x86_64
ApportVersion: 2.28.1-0ubuntu3.8
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: XFCE
Date: Fri Jan  9 13:49:26 2026
InstallationDate: Installed on 2024-10-25 (441 days ago)
InstallationMedia: Xubuntu 24.04.1 LTS "Noble Numbat" - Release amd64 (20240827)
SourcePackage: beautifulsoup4
UpgradeStatus: No upgrade log present (probably fresh install)

** Affects: beautifulsoup4 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug noble

** Attachment added: "dpkg -l 'python3*' output"
   https://bugs.launchpad.net/bugs/2138135/+attachment/5938448/+files/pkg

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2138135

Title:
  partially installed module bs4 (python3 module)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/beautifulsoup4/+bug/2138135/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to