Spurious "Module ... has already been imported" warnings

Bug #500621 reported by Max Bowsher
34
This bug affects 8 people
Affects Status Importance Assigned to Milestone
pygments (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Upon upgrading to lucid, I noticed some bzr commands throwing warnings. Traced to a minimal repro case:

$ python -c 'import pygments.plugin'

Which warns:

/usr/lib/pymodules/python2.6/pygments/plugin.py:39: UserWarning: Module pygments was already imported from /usr/lib/pymodules/python2.6/pygments/__init__.py, but /usr/lib/pymodules/python2.6 is being added to sys.path
  import pkg_resources

Which seems confusing. Therefore I patched pkg_resources.py to display the actual strings being compared, which gave:

/usr/lib/pymodules/python2.6/pygments/plugin.py:39: UserWarning: Because /usr/share/pyshared/pygments/__init__.py does not start with /usr/lib/pymodules/python2.6
  import pkg_resources

Therefore it can be seen that the code is being upset by the /usr/lib/pymodules vs. /usr/share/pyshared split layout with symlinks. I'm unsure what to do about it though.

ProblemType: Bug
Architecture: i386
Date: Sat Dec 26 20:18:41 2009
DistroRelease: Ubuntu 10.04
EcryptfsInUse: Yes
Package: python-pkg-resources 0.6.8-1ubuntu2 [modified: usr/share/pyshared/pkg_resources.py]
PackageArchitecture: all
ProcEnviron:
 LC_COLLATE=C
 PATH=(custom, user)
 LANG=en_GB.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.32-9.13-generic
SourcePackage: distribute
Tags: lucid
Uname: Linux 2.6.32-9-generic i686

Revision history for this message
Max Bowsher (maxb) wrote :
Revision history for this message
Max Bowsher (maxb) wrote :

This would seem to have something to do with pygments.__file__ being the path to the .pyc file (which is not a symlink) on karmic, but being the path to the .py file (which is a symlink) on lucid.

Revision history for this message
Max Bowsher (maxb) wrote :

This may actually just be a weird local problem, as purging and reinstalling the python-pygments package fixed the problem for me. I'll find another lucid machine to compare.

Matthias Klose (doko)
affects: distribute (Ubuntu) → pygments (Ubuntu)
Revision history for this message
Max Bowsher (maxb) wrote :

This has reoccurred on a second independent karmic->lucid upgrade, so I believe there's a real issue here.

Revision history for this message
Max Bowsher (maxb) wrote :

sudo mv /usr/lib/pymodules/python2.6/pygments/__init__.pyc /usr/lib/pymodules/python2.6/pygments/__init__.pyc.broken
sudo update-python-modules python-pygments.public

made the warning go away

Revision history for this message
Brent Kraczek (kraczek) wrote :

I have a similar problem using matplotlib, also on a karmic->lucid upgrade, so it's probably not the specific pymodule, but however the loading of python modules got updated.

Revision history for this message
stefaanlippens (stefaan-lippens) wrote :

I had a similar problem with Sphinx (package python-sphinx) after a karmic to lucid upgrade.

I got errors for modules pygment, roman, docutils, sphinx and jinja2.

Fixed it like proposed in #5: rename/remove the pyc files and run "sudo update-python-modules python-foobar.public"

Changed in pygments (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.