iptcinfo: Can not import: Newbie not really knowing what he is doing

Discussion in 'Python' started by mcl, Jul 12, 2010.

  1. mcl

    mcl Guest

    My Code

    `import os
    from PIL import Image
    from iptcinfo import IPTCInfo
    info = IPTCInfo('test.jpg')
    print info.keywords, info.supplementalCategories, info.contacts
    caption = info.data['caption/abstract']
    print caption`

    running Win XP SP3

    I get the message

    No module: iptcinfo

    I have downloaded iptcinfo and placed it in python27\Lib\site-packages

    I guessed that was the right place, because that is where PIL ended
    up, but that had a fancy installer with it.

    As you will appreciate, I am very much an amateur in all this. I can
    code a bit of python, but where everything goes and links is a
    complete mystery. All I want is to write a quick script which
    extracts the Caption field from a directory of JPEGS. I get the
    filenames and the dimensions with PIL, but I need IPTCinfo to get at
    the Caption field.

    If anyone can throw any light on what I need to do or which stupid
    mistake I have made, I would be most grateful.

    mcl, Jul 12, 2010
    1. Advertisements

  2. mcl

    Nick Raptis Guest

    Hi Richard!
    You did place it in the right path, but the "fancy installer" does one
    more thing, it registers the package into the python-path, so python can
    get to it.
    I've long switched from windows unfortunately and can't remember the way
    it does this though, so you can do it manually.

    Have some good news though: I looked in the IPTCinfo package and it does
    indeed include a setup.py, which is a standard way of installing python
    All you need to do is unpack the package to any folder and run
    setup.py install
    from that folder, which should take care of everything for you.

    Some documentation on installing packages for you to read:

    Nick Raptis, Jul 12, 2010
    1. Advertisements

  3. mcl

    mcl Guest

    What a star. It is all now working.

    I will try to look at the reference you mentioned, but at the moment I
    can not even figure out why 'python' on its own does not work. I
    would have thought the installation would have set the appropriate
    environment variables, but it does not seem to have. I have to give
    the full path name to python.exe. Just remembered SET at DOS prompt,
    but no mention of PYTHON anywhere.

    Thank you very much again - I now have a list of all my JPEGS and
    their CAPTIONS.

    mcl, Jul 12, 2010
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.