2010-01-13

64 bit python installation issues on 64 bit Windows 7

After installing 64 bit Windows 7 at work, I got a problem of installing many python utilities that search for installed python locations is windows registry. distutils (setuptools-0.6c11.win32-py2.6.exe) still could not find 64 bit python installation, as well as develer's Unofficial MinGW GCC binaries for Windows (I still do not have a solution for that one :( ).

Actually, what helped me with disttools, was a http://www.mail-archive.com/distutils-sig@python.org/msg10512.html group thread. The currently available 64 bit python installation is registering python in a new location in windows registry. So one have to use a modified script for registering python the old way:

#
# script to register Python 2.0 or later for use with win32all
# and other extensions that require Python registry settings
#
# written by Joakim Loew for Secret Labs AB / PythonWare
#
# source:
# http://www.pythonware.com/products/works/articles/regpy20.htm
#
# modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html

import sys

from _winreg import *

# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix

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

def RegisterPy():
    try:
        reg = OpenKey(HKEY_CURRENT_USER, regpath)
    except EnvironmentError as e:
        try:
            reg = CreateKey(HKEY_CURRENT_USER, regpath)
            SetValue(reg, installkey, REG_SZ, installpath)
            SetValue(reg, pythonkey, REG_SZ, pythonpath)
            CloseKey(reg)
        except:
            print "*** Unable to register!"
            return
        print "--- Python", version, "is now registered!"
        return
    if (QueryValue(reg, installkey) == installpath and
        QueryValue(reg, pythonkey) == pythonpath):
        CloseKey(reg)
        print "=== Python", version, "is already registered!"
        return
    CloseKey(reg)
    print "*** Unable to register!"
    print "*** You probably have another Python installation!"

if __name__ == "__main__":
    RegisterPy()

or just inject the following REG file into your registry if you are using python 2.6 installed in C:\Python26 directory

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Python]

[HKEY_CURRENT_USER\Software\Python\Pythoncore]

[HKEY_CURRENT_USER\Software\Python\Pythoncore\2.6]

[HKEY_CURRENT_USER\Software\Python\Pythoncore\2.6\InstallPath]
@="C:\\Python26"

[HKEY_CURRENT_USER\Software\Python\Pythoncore\2.6\PythonPath]
@="C:\\Python26;C:\\Python26\\Lib\\;C:\\Python26\\DLLs\\"

42 comments:

sfletche said...

was having some problems installing psycopg for postgres/postgis. used the registry contents that you posted above and it appears this saved me from having to reinstall python as 32-bit on my 64-bit windows 7 machine. thanks for the post!

Unknown said...

yep, thanks :)

Anonymous said...

It worked for me too (installing PIL). Thank you so much.

Unknown said...

Added those lines to a txt file then changed to a .reg file and merged to the registry and it worked for me too!

Unknown said...

The problem is the pywin32 is a 32 bit installer, it will look for the Python reg entries in the Wow6432Node, the following .reg file will add the entries, ensure the paths are correct for your install.

Tested with Windows 7 x64 and python 3.2.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2\Help]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2\Help\Main Python Documentation]
@="C:\\Python32\\Doc\\python32.chm"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2\InstallPath]
@="C:\\Python32\\"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2\InstallPath\InstallGroup]
@="Python 3.2"

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2\Modules]

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python\PythonCore\3.2\PythonPath]
@="C:\\Python32\\Lib;C:\\Python32\\DLLs"

Dima Basavin said...

thanks a lot! it worked
(had a problem with pysqlite for python27)

maGo! said...

Thank you, worked like a charm, installed pywin32

Galal said...

Thanks a lot. =D

Jennifer said...
This comment has been removed by the author.
Jamie Faye Fenton said...

I used RegEdt32 and went into the HKEY_LOCAL_MACHINE hive, selected the python key, and used the export command to create a file I called pyreg.reg. This made a file similar to the one shown in the comment. I then replaced all references to HKEY_LOCAL_MACHINE with HKEY_CURRENT_USER (in NotePad), and saved the result as pyreg1.reg. I then executed on the cmd line:

regedt32 pyreg1.reg

(The effect of doing this is to capture the exact version of Python you have installed, including any changes to the registry layout it has).

Juan Pablo said...

Thank you! that worked for me!

Andrey Gannochka said...

Thank you very much! (Problem with Mabot installation has been fixed.)

Unknown said...

Used the .reg method, worked like a charm for Python27.

Thanks a lot!

Unknown said...

thx man i got so many solution , but just your are perfect
thx a lot

Anonymous said...

Thanks for this page on what to fill in for registry. It was strange though that 2.6 and 2.7 registered properly and 3.3 did not. I'm not sure if python is like Visual Studio where you have to have them in the proper order but I tried my best to do that.

Alex Irae said...

It workeeeed!

CTorres said...

you are an angel

chidambaram said...

Thank you may you live forever and continue the work forever.

Unknown said...

You saved my day!!

Anthony said...

Prevented me from having to do this manually; thus, very useful, and much appreciated.

Unknown said...

Thank you very much for the post. Helped a lot.

Alvin Paul said...

The solution is working on my PC. I also have windows 7 and suffers the same problem with it.

Alvin
www.ddlforall.blogspot.com

Unknown said...

Thank you, it worked for solving "unable register" problem when installing psycopg for postgres.

Unknown said...

It is Very Helpfull. I like it so much, Thanksss a lot.

free crack software | photo mechanic 5 serial

adysys said...

worked great. thanks alot

Unknown said...

I appreciate thsi posting..its very helpful. Thanks!!!
cracked software download | 4k stogram license key

Unknown said...

Helped alot..thanks for sharing!
pftrack download

Unknown said...

Amazing thanks for posting such a great tutorial its really very helpful for Php developer's in installing Python.Click here to download more Free Crack Software's == >
Latest Crack Software | Download Crack Software | Free Crack Software
Free Download Software | New Software Download

https://cracklink.info/idm-crack/ said...

Thanks for these informative website. Also visit this site :-)... 4K Stogram Crack

EZcrack said...

Appreciation is a wonderful thing...thanks for sharing kepp it up.Photo Mechanic Crack
ImageRanger Pro Crack
Renee PassNow Crack
NCH Debut Video Capture Crack
Windows 7 All In One ISO
Window 7 Ultimate ISO Crack

cracklayer said...

Download Full Crack click the following;
https://cracklayer.com/falcon-box/
https://cracklayer.com/z3x-lg-tool/
https://cracklayer.com/norton-security/

cracklayer said...

https://cracklayer.com/noteburner-music/
https://cracklayer.com/panda-antivirus/
https://cracklayer.com/idm-crack/

publiccrack.com said...


If you are interested in Android Apps, PC Softwares and MAC Applications then you can visit our official websites for registered applications where you can download full free without paying any charges.

PUBLIC CRACK

Javed said...

You Can Also Download Free Software & Mac
https://tijacrack.com/isobuster-crack/

Peck Marsh said...

Wonderful work! This is the kind of info that is meant to be shared across the internet. Disgrace on the search engines for not positioning this post higher! Come on over and consult with my website.
So, I would like to Share VideoSolo Screen Recorder Crack with you.
Windows 7 Ultimate ISO

Smith Michael said...

I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me
Windows 7 Ultimate ISO
VideoSolo Screen Recorder Crack

Unknown said...

I really appreciate your initiative and your blog approach it helps many people like myself.

do visit my site for new and updated software : VovSoft VCF to TXT Converter

Arif Khichi said...

Thanks to share this content aiseesoft screen recorder crack

ryanmay1177 said...

Really Good Work Done By You...However, stopping by with great quality writing, it's hard to see any good blog today.
4K Stogram 3.4.3.3630 Crack

unknow said...

I have to say that during my time browsing through the internet I have read many articles/ Blogs but yours particularly have impressed me how you have written this masterpiece is mind-blowing. Kindly visit my website for new and latest Cracks : Wondershare AllMyTube

Software said...

Nice explanation and article. Continue to write articles like these, and visit my website at https://usacrack.info/ for more information.

StudioLine Web Designer 4.2.66 Crack

waresoftz123 said...

this amazing Software.
PCHelpSoft Driver Updater Crack
zoom player max Crack
Soni Typing Crack