Sick of pkg_resources Warnings?

Create a sitecustomize.py in your site-packages with the following code:

import warnings
warnings.filterwarnings('ignore',
  message=r'Module .*? is being added to sys.path', append=True)

3 Responses to “Sick of pkg_resources Warnings?”

  1. I think i get one of these? This is what I’ve been getting:

    UserWarning: Module _mysql was already imported from /var/lib/python-support/python2\
    .5/_mysql.so, but /var/lib/python-support/python2.5 is being added to sys.path
    import pkg_resources

    Comment by Braydon Fuller — Tuesday, February 19th, 2008 @ 10:30 pm
  2. Yes. Happens if you are playing with sys.path to inject another lib but there is an egg added later on. Especially for scripts very annoying.

    Comment by Armin Ronacher — Tuesday, February 19th, 2008 @ 11:04 pm
  3. It is very annoying. I sidestepped the issue and tried the same using postgresql, and it went away. Weird thing is that for the wsgi bridge file I play with sys.path to import some modules, however I get this when I run the script that doesn’t append anything to the sys.path, so it must be happening someplace else.

    Comment by Braydon Fuller — Tuesday, February 19th, 2008 @ 11:47 pm

Leave a Reply

cogitations driven by wordpress