setuptools, accessing ressource files

PJ Eby pje at telecommunity.com
Sat Oct 3 10:32:28 EDT 2009


On Oct 2, 7:04 am, Patrick Sabin <patrick.just4... at gmail.com> wrote:
> I use setuptools to create a package. In this package I included some
> images and I checked that they are in the egg-file. The problem is how
> can I access the images in the package?
>
> I tried pkgutil.get_data, but only got an IOError, because the EGG-INFO
> directory doesn't exist.
>
> I tried
> pkg_resources.get_distribution('dist').get_metadata('images/image.png')
> with a similar error (IOError)
>
> What is the best way to access images distributed in an egg file?

The resource_stream(), resource_string(), or resource_filename()
functions:

http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access

>
> -Patrick




More information about the Python-list mailing list