setuptools, accessing ressource files

P

Patrick Sabin

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?

-Patrick
 
P

PJ Eby

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top