Register QGIS Python Console

Disclaimer: You do the following at your own risk.

To use Python Image Library with QGIS you need to install PIL into the QGIS python install location. Open up your version of QGIS and make sure the Python Interpreter is available (Plugins | Python Console). Then type in the code below. This will register the version of Python used by QGIS in the Windows registry. Other versions e.g. 2.6 for pythonxy will be registered elsewhere so there shouldn’t be a conflict but I wouldn’t count on it. Then fire up regedit and browse to HKEY_LOCAL_MACHINE | SOFTWARE | Python | Pythoncore and change the name of the Key entry from whatever very long name it is to 2.x where x is the version of Python 2 being used: so for QGIS 1.7 it should be changed to 2.5.

Then go to and get the correct binary of PIL for your QGIS install. It is an exe so it should pick up the registered version and install to the correct location. Then you should be able to use PIL from QGIS.

<pre style="padding-left: 60px;"># script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
# written by Joakim Löw for Secret Labs AB / PythonWare
# adapted by ajg
# source:
# <a href=""></a>

import sys

from _winreg import *

# tweak as necessary
version = sys.version
installpath = sys.prefix

regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (installpath, installpath, installpath)

    reg = OpenKey(HKEY_LOCAL_MACHINE, regpath)
        reg = CreateKey(HKEY_LOCAL_MACHINE, regpath)
        SetValue(reg, installkey, REG_SZ, installpath)
        SetValue(reg, pythonkey, REG_SZ, pythonpath)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A Website.

Up ↑

%d bloggers like this: