ImportError while importing winreg module of python

Pravar Jawalekar picture Pravar Jawalekar · Jun 21, 2012 · Viewed 16.9k times · Source

I wanted to use winreg module of python for working with windows registry. But when I try to import winreg module, it gives ImportError.

Python 2.4.3 (#1, Dec 11 2006, 11:39:03) 
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import __winreg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named __winreg
>>> import _winreg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named _winreg

Do I need to install this module separately ? Any suggestions would be useful.

Answer

C&#233;dric Julien picture Cédric Julien · Jun 21, 2012

It looks like you're trying to import a windows only module on a *nix platform (RedHat is not Windows).

_winreg – Windows registry access

Platforms: Windows