[Distutils] `pkg_resources.require()`doesn’t see wxPython

Ram Rachum cool-rr at cool-rr.com
Sat Nov 14 14:46:11 CET 2009

Tarek Ziadé <ziade.tarek <at> gmail.com> writes:

> On Fri, Nov 13, 2009 at 9:55 PM, cool-RR <cool-rr <at> cool-rr.com> wrote:
> > I'm having trouble using Distribute's pkg_resources.require(). I posted a
> > question on StackOverflow:
> > http://stackoverflow.com/questions/1728676/pkgresources-require-doesnt-see-
> > I hope someone here has an answer.
> > Thanks, Ram.
> If pkg_resources doesn't find it, it might be that it doesn't have
> somehow an egg-info folder or file in site-packages,
> or that the project name is not what you are expecting ('wxpython')
> Look for that egg-info and search for the name of the project. In
> *egg-info/PKG-INFO or in egg-info itself.
> Tarek
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG <at> python.org
> http://mail.python.org/mailman/listinfo/distutils-sig

Well, about the unexpected name thing, I don't think so, cause I printed the 
entire working_set and looked at the names one-by-one, and wxPython wasn't there 
in any kind of different name.

I haven't investigated that egg-info thing, because it doesn't matter much to me 
what is the technical reason for this. The fact that `require` gave a false 
positive, and not even under any special circumstances, just a standard Windows 
installation of wxPython, is reason enough not to use it in my project.

Also, before I came to this conclusion I noticed the kind of error that 
pkg_resources raises:

    pkg_resources.DistributionNotFound: my-dependency

That is not too helpful. Yes, I noticed you have a todo comment on that error to 
make it more informative:

    raise DistributionNotFound(req)  # XXX put more info here

So here's a patch for you:

    raise DistributionNotFound('''The distribution %s is needed for this \
program, but it was not found on this system. Please search for it on the \
internet, then download and install it, then try this program again.''' % req)

Because when a potential user has just downloaded my program and he's trying it 
out, the last thing I want to do is scare him away with an obscure error 


More information about the Distutils-SIG mailing list