import _winreg does not work. How do I fix?

Jimmy Retzlaff jimmy at retzlaff.com
Tue Nov 25 07:18:04 EST 2003


John Sellers wrote:
> Miki Tebeka wrote:
> > There is no _winreg on cygwin, only on "true" win32 python.
> > If you must use cygwin you can either patch _winreg to work for you
or
> > use cygwin's regtool (try regtool --help)
>
> Sounds reasonable, but if what you say is true, I am surprised that
not
> all Python 2.3.2 releases are not equal.
> 
> How good is your information?  Is it authorative?

While Miki's information may or may not be authorative, it does appear
to be true.

Python has different modules available on different platforms. See
http://www.python.org/doc/current/modindex.html for a list of modules.
The modules with one or more platforms in parenthesis next to them are
platform specific.

_winreg is documented as being a Windows specific module. As far as
Python is concerned, cygwin is a Unix platform, not a Windows platform.
As evidence of this try importing modules which the Python documentation
calls Unix specific and modules called Windows specific on cygwin Python
and on Windows Python:


Python 2.2.3 (#1, Jun 19 2003, 12:10:13)
[GCC 3.2 20020927 (prerelease)] on Cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import crypt
>>> crypt
<module 'crypt' from '/usr/lib/python2.2/lib-dynload/crypt.dll'>
>>> import _winreg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named _winreg


And on "true" Win32 Python:


Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import _winreg
>>> _winreg
<module '_winreg' from 'C:\Python23\DLLs\_winreg.pyd'>
>>> import crypt
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named crypt


If you don't like Miki's suggestion of using regtool, then you could run
win32 Python side-by-side with cygwin Python and use an IPC mechanism to
communicate between the two.

Jimmy






More information about the Python-list mailing list