»
S
I
D
E
B
A
R
«
Tips and Tricks in Installation of PIL on Windows 7 / 2008 64bit
Nov 12th, 2009 by evereq
  1. 1) libtiff
download sources (zip) from http://gnuwin32.sourceforge.net/packages/tiff.htm
2) zlib
download sources (zip) from http://gnuwin32.sourceforge.net/packages/zlib.htm
3) libjpg
download sources (zip) from http://gnuwin32.sourceforge.net/packages/jpeg.htm
http://www.wiredfool.com/2005/10/29/how-to-build-the-python-imaging-library-for-windows/
http://boodebr.org/main/python/build-windows-extensions

Installation of Python Image Library (PIL)

It will be a problems with PIL installation on  Windows 7 64 bit, so you will need to install library from source code:

  1. Download PIL library source code from http://www.pythonware.com/products/pil/
  2. Unpack it to any  folder, for example C:\PIL
  3. Run in command prompt (cmd):
    cd c:\PIL
    python setup.py install

    This will install library, but without support for TKINTER, JPEG, ZLIB (PNG/ZIP) and FREETYPE2 (i.e. actually without anything :D )

So let’s add support for at least JPEG and PNG. To do this, you will need to download following libraries:

  1. libtiff – download sources (zip) from http://gnuwin32.sourceforge.net/packages/tiff.htm
  2. zlib – download sources (zip) from http://gnuwin32.sourceforge.net/packages/zlib.htm
  3. libjpg – download sources (zip) from http://gnuwin32.sourceforge.net/packages/jpeg.htm

Following blog posts will help you to continue with installation:

Notes:

  1. Possible that you will need to remove
     include <unistd.h>

    from some *.h source files as this needed to be included only on Unix (ok, at least not on Windows)
    For example you will need to delete such line from zconf.h in zlib sources before try to run nmake for zlib.

  2. Don’t forget to set PIL library pointers (in setup.py of PIL) to point to the locations where you put zlib, libjpg and libtiff. If you forget to setup  - PIL will not found them and you will get what I describe in the beging of post – I.e. nothing :D .
    This is for example what you need to set for zlib in setup.py of PIL in case if you copy zlib sources to c:\PIL\zlib folder (I assume that you unzip PIL into c:\PIL here):

    ZLIB_ROOT = './zlib'
  3. You also can found yourself with finding all the 32-bit times “__time32_t” and changing it to “time_t” for 64-bit conversion ;-)
Windows 32bit vs 64bit
Oct 14th, 2009 by evereq

if you have 64 bit version of Microsoft Windows (2008, 7 or 2003) it seems like it’s good idea to setup this version (instead of 32 bit) on both developer machine and production servers if you select .NET platform for your Web application and IIS as your hosting solution.

Here are some reasons why:
1) Serialization works much better on 64 bit OS in processes that hosted by IIS (at least for IIS 6,7,7.5). Means that if you want to serialize huge object (for example DataTable) in 32 bit OS you can get “Out Of memory” exception, while on 64 bit OS this works fine! As probably you know, IIS process on 32 bit OS can be practically maximum about 1200Mb size (while theoretically maximum is 2Gb for 32 bit OS) and for some scenarios this can be a not enough (for example if you going to use in-memory / in-process cache etc)
2) If you develop your system on 64 bit OS, you can be sure that it will work well on both 32 bit and 64 bit OS (at least you can check how it works). Usually problems start coming if you develop and test on 32 bit and than decide to host under 64 bit OS…. So why not to avoid this? Cost of both 32 bit and 64 bit OS usually is the same (at least for MS products), so if you don’t have some specific requirements (for example some of your library does not works under 64 bit machine) it looks like make sense to go with 64 bit!
3) In latest Server OS Windows 2008 R2, Microsoft removes 32 bit support and this version available only as 64 bit OS. That is why it looks like now make sense also to move to 64 bit on developer machine!

So, I found for myself following best software combination available today to develop / host .NET Web Application:

1) Developer Machine: Windows 7 Professional / Ultimate / Enterprise 64 bit with at least 8Gb PC memory (as you probably will want to run some virtual machines, your ReSharper will eat a log of memory in whole solution analyzing mode, Visual studio process can grow to 1Gb itself, Microsoft SQL Server same etc)

2) Hosting Server: Windows 2008 R2 (64 bit) with at least 4Gb memory even if you enable only IIS here (i.e. use server just as Web Server, but not as SQL Server etc), but use huge Sessions objects (not recommended, unless you already have stupid code that do so) or in memory (in process) huge Cache (ASP.NET or for example EntLib Cache etc).

Using such combination you will avoid a lot of problems with “Out of memory” related issues!

P.S. yes, yes, I know – instead of “Out of Memory” issue, you will get a lot of problems to make some soft working well under 64 bit (problems with Paths, dll versions etc). But time that you spend to fix all this setup issues, will save you much more time with Visual Studio (or other soft) crashes or when you go live with your application and get 100 times per day same “out of memory” in your logs! I don’t speak here about performance benefits here (if they exists at all) – it make sense to create special post for this!

P.P.S. sure thing, if you get such “out of memory” exceptions it is problems in your code (or in Microsoft code in some cases, like Visual Studio for example, but anyway it’s your fault! :D ) and you do something bad… In most cases you can change design and avoid such issues (split huge objects to smaller, don’t store in sessions or cache huge objects graphs, etc). In some cases you simply cannot change anything – it’s by requirements this way or you just have old stupid code that you need quickly to fix! In such cases, moving to 64 bit environment can be good temporary solution that will give you time to improve design / coding discipline! Just be worried – if you don’t change yourself – you will end up with same out of memory exceptions on 64 bit OS (store all 100Gb database as one huge serialized dataset in memory cache for example :) ha ha… I see something like this before really!)

»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright 2008–2009 EvereQ.com All rights reserved.