2008-11-29

Install PIL under cygwin python 2.5

The Python Imaging Library (PIL) seems to be a nice module to dynamically create PNG images for web applications. I managed to install the PIL 1.1.6 module under cygwin, but it took a few turns to get it going. My environment:

  • cygwin 1.5.25-15
  • python 2.5
  • Python Imaging Library 1.1.6 Source Kit (here)
Here are the steps that worked for me:
  1. Download and unpack the PIL source package, open a bash shell and type:
    wget http://effbot.org/downloads/Imaging-1.1.6.tar.gz
    tar xzf Imaging-1.1.6.tar.gz
    cd Imaging-1.1.6
  2. Try to build:
    python setup.py build_ext -i
    At this point I got the following error message, and the build would just hang forever:
    5 [main] python 4188 C:\cygwin\bin\python.exe: *** fatal
    error - unable to remap C:\cygwin\bin\tk84.dll to
    same address as parent(0x18710000) != 0x18C10000
    107 [main] python 5852 fork: child 4188 - died waiting for dll
    loading, errno 11
    According to that error message, tkr84.dll's load address is clashing with another DLL.

  3. "Rebasing" the offending tkr84.dll to a different address is the solution. Here is how to do it.

    First close all cygwin processes to ensure that tkr84.dll is unloaded. In Windows Task Manager confirm that no cygwin processes like gcc or python are running. If there are processes left, kill them.

    If you have Microsoft Platform SDK installed, you can use it's rebase.exe from a command prompt:
    From Start run: cmd.exe
    > cd \cygwin\bin
    > rebase -b 0x1000000000 tk84.dll
    Otherwise you can try cygwin's version of rebase, but it appears it works only from the lightweight ash shell:
    From Start run: C:\cygwin\bin\ash.exe (correct path as needed)
    $ cd /bin
    $ ./rebase -b 0x1000000000 tkr84.dll
  4. Retry to build, test, and install:
    python setup.py build_ext -i
    python selftest.py
    python setup.py install



4 comments:

Jeff Allen said...

Thanks, worked for me. But I had to remove the "r" in tkr85.dll.

-jeff

id said...

Thanks for that! Now I can continue with the Python Challenge...

Beginner said...

Once I use rebase -b 0x100000000 tk84.dll. It tells me that rebase: Base address 0x100000000 too big for 32 bit machines.


what should I do. THanks!

jowdjbrown said...

It is great to have the opportunity to read a good quality article with useful information on topics that plenty are interested on.I concur with your conclusions and will eagerly look forward to your future updates.LKW chiptuning