[gdal-dev] Installing additional packages for python in OSGeo4W

Matt Wilkie matt.wilkie at gov.yk.ca
Fri May 7 18:21:02 EDT 2010

Aleksey, The registry script will only make changes if it does not find 
a key for the major version of python in the current environment 
settings  (2.4, 2.5, etc) . Meaning, it's safe and won't mangle your 
existing install, but neither will it make o4w python generally 
available. What follows are three approaches you might try. I've use the 
first two with success, no guarantees they'll work for anyone else, the 
3rd is theortical.

      == Parallel  ArcGIS and Osgeo4W python installs ==

You can switch the default system python of the same major version, 
python 2.5 for example, between the arcgis and o4w  by creating a 
registry file for each and delete/import at need. For example:

1. store existing py registry settings, open CMD shell (must be 
admin-level shell on win7 and vista) and:

    regedit /e arcgis-python-registry-hklm.txt
    regedit /e arcgis-python-registry-hkcu.txt

2. Only one of the files will be created. Edit it and put a minus symbol 
in front of each [...] block, and save as 


3. Delete the current python registry by importing the remove_*.txt.

    regedit remove_arcgis-python-registry-hkcu.txt

4. Open an o4w command shell and run register-python.py. Repeat #1 & #2 
to save o4w registration and create removal version:

    regedit /e o4w-python-registry-hklm.txt
    regedit /e o4w-python-registry-hkcu.txt

Now you are free to run whatever binary installers you need. Switch 
between the installs by a) import removal registry.txt, b) import wanted 

      == Shared ArcGIS and Osgeo4W python install ==

1. Uninstall existing arcgis python (or de-register as above).
2. Open an o4w command shell and run register-python.py
3. Install pywin32 for corresponding python (*win32-py2.5.exe at the moment)
3. Put "arcgisscripting.py"[1] in "%pythonhome%\Lib\site-packages"

[1] http://www.yukongis.ca/@api/deki/files/12/=arcgisscripting.py

      == Upgrade ArcGIS to py2.6, leave O4W py2.5==

One method which might work is to uninstall the regular system/arcgis 
python and upgrade it to 2.6. Then run the register-python.py from an 
o4w command shell. This will make both versions available to standard 
python binary installers. I believe the recipe here, 
http://www.yukongis.ca/How_To/UpgradingPython, will work for 
py2.6+arcgis9.3 but have not personally tried it.

I believe ArcGIS 10 embeds python 2.6 into it's own install tree and 
doesn't make it available system wide; we'll see.


matt wilkie
Geomatics Analyst
Information Management and Technology
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax

On 07/05/2010 11:08 AM, Aleksey Naumov wrote:
> Hi Matt,
> Thank you for your help. I noticed that you created a script to record 
> python in registry, but I think I might have to try it as the last 
> resort. I already have Python 2.5 (a regular version, not from 
> OSGeo4W), and I would have to remove that before attempting to run the 
> registry script, correct? I am hesitant to remove the "normal" Python 
> 2.5 since it is used for other things, including Arc geoprocessing 
> scripts.
> Meanwhile, I was able to install the xlrd and SQLAlchemy packages from 
> downloaded sources with "python setup.py install" from inside the 
> OSGeo4W shell; that seemed to work. Tried to do the same for IPython 
> (0.10) and got the following error upon install:
> "The procedure entry point ?PyWinGlobals_Ensure@@YAXXZ could not be 
> located in the dynamic link library pywintypes25.dll"
> The same error pops up when trying "import IPython" or "import 
> win32process". This looks like a win32 extension problem, or is it? 
> Anyway, I reran the OSGeo4W setup to reinstall python-win32 (2.12-1), 
> but that did not help.
> Is there any way to move forward without resorting to removing the 
> "normal" Python 2.5? I guess if I did that I should be able to 
> register OSGeo4W's python with your script and then install IPython 
> via executable or via easy_install (for which again I'd need to first 
> install setuptools from an executable)?
> In general, what is the best way to install additional python packages 
> in OSGeo4W? Should I be using "apt" or "setup" (noticed both under 
> Commandline Utilities in the OSGeo4W setup program)? Does OSGeo4W 
> provide it's own setuptools?
> Thank you,
> Aleksey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20100507/e3e89b75/attachment.html

More information about the gdal-dev mailing list