UserWarning printed on import pkg_resources'

Bug #810019 reported by Scott Moser on 2011-07-13
This bug affects 4 people
Affects Status Importance Assigned to Milestone
distribute (Debian)
distribute (Ubuntu)
paste (Ubuntu)
Dave Walker
Dave Walker

Bug Description

$ python -c 'import pkg_resources'
<smoser> -c:1: UserWarning: Module paste was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path

$ dpkg-query --show python-pkg-resources
python-pkg-resources 0.6.16-1

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: python-pkg-resources 0.6.16-1
ProcVersionSignature: User Name 3.0-3.4-virtual 3.0.0-rc5
Uname: Linux 3.0-3-virtual x86_64
Architecture: amd64
Date: Wed Jul 13 17:15:31 2011
PackageArchitecture: all
 PATH=(custom, user)
SourcePackage: distribute
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

Scott Moser (smoser) wrote :
Scott Moser (smoser) wrote :

since the last update of 'distribute' was some 8 weeks ago, this is not filed correctly, but i'm not sure what the correct source is.

Barry Warsaw (barry) wrote :

This only happens after `apt-get install python-paste` so that's where the problem must be. Having trouble moving it to that project though.

Scott Moser (smoser) on 2011-07-20
affects: distribute (Ubuntu) → paste (Ubuntu)
Changed in paste (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Scott Moser (smoser) wrote :

The debian bug seems to think that this is related to 'distribute', and has info on it occuring also with 'import MySQLdb'

affects: paste (Ubuntu) → distribute (Ubuntu)
Changed in distribute (Debian):
status: Unknown → New
Scott Moser (smoser) on 2011-09-02
tags: added: server-o-rs
Dave Walker (davewalker) on 2011-09-03
Changed in distribute (Ubuntu):
milestone: none → ubuntu-11.10-beta-2
Gediminas Paulauskas (menesis) wrote :

This happens with paste because it is not installed correctly. namespace_packages.txt and Paste-*.pth are removed after install, and this confuses dh_python2 and python import machinery.

Leaving those files in place eliminates the cause for the warning.

Scott Kitterman (kitterman) wrote :

paste is converted to dh_python2 in Debian. Updating that might help.

Barry Warsaw (barry) wrote :

Piotr, do you have an opinion on this?

Iain Lane (laney) wrote :

The find line which attempts to remove *.pth doesn't do so. You need to add parentheses around it like so

  find $(PKGDIR) \( -name '*.pth' -or -name 'namespace_packages.txt' \) -delete

Julian Taylor (jtaylor) wrote :

the issue also occurs with python-argparse installed:

$ mkdir -p external/argparse
$ touch external/
$ echo "import argparse" > external/argparse/
$ python -c "import external.argparse; import pkg_resources"
-c:1: UserWarning: Module argparse was already imported from /usr/lib/python2.7/argparse.pyc, but /usr/lib/python2.7/dist-packages is being added to sys.path

Iain Lane (laney) wrote :

Removing the .pth breaks paste (thanks Daviey):

(sid-amd64)root@raleigh:/srv/home/laney# python -c 'import paste'
(sid-amd64)root@raleigh:/srv/home/laney# rm /usr/lib/python2.6/dist-packages/Paste-
(sid-amd64)root@raleigh:/srv/home/laney# python -c 'import paste'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named paste

Piotr Ożarowski (piotr) wrote :

as Iian pointed out, my last upload broke the find call and that's why you're getting this warning.

Ian: removing .pth file is the right fix, if it doesn't work for you, something else is wrong on your system. Are you sure you didn't remove paste directory as well?

Piotr Ożarowski (piotr) wrote :

heh, file is missing as well

Iain Lane (laney) wrote :

debdiff for re-merge.

Piotr, do you want to take this fix in Debian too? Move -mochikit to suggests since the reason for moving it up to recommends doesn't apply any more.

Changed in distribute (Ubuntu Oneiric):
status: Confirmed → Opinion
status: Opinion → Invalid
Changed in paste (Ubuntu Oneiric):
status: New → Confirmed
importance: Undecided → Medium
milestone: none → ubuntu-11.10

A fixed paste (and the other two paste packages too) was already uploaded to

Dave Walker (davewalker) wrote :

Merge form sid currently in unapproved queue.

Changed in paste (Ubuntu Oneiric):
status: Confirmed → Fix Committed
assignee: nobody → Dave Walker (davewalker)
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package paste -

paste ( oneiric; urgency=low

  * Merge from debian unstable (LP: #810019). Remaining changes:
    - debian/control: Demote libjs-mochikit back to suggests because dh_python2
      doesn't have the same symlink problem as python-support.

paste ( unstable; urgency=low

  * Add also missing file

paste ( unstable; urgency=low

  * Remove .pth file (introduced in last upload by accident)
  * Add build-indep and build-arch targets in debian/rules
  * Let dh_sphinxdoc handle documentation files, python-sphinx build
    dependency bumped to 1.0.7+dfsg-1
 -- Dave Walker (Daviey) <email address hidden> Mon, 26 Sep 2011 18:45:19 +0000

Changed in paste (Ubuntu Oneiric):
status: Fix Committed → Fix Released
Iain Lane (laney) wrote :

What was wrong with my diff?

Dave Walker (davewalker) wrote :

Apologies Laney, I thought yours was not based on a merge. I should have looked closer. Sorry.

Iain Lane (laney) wrote :

On Tue, Sep 27, 2011 at 11:37:09AM -0000, Dave Walker wrote:
> Apologies Laney, I thought yours was not based on a merge. I should
> have looked closer. Sorry.

No worries, was just wondering if I messed something up :-)

tags: added: rls-mgr-o-tracking
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

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