ImportError while importing winreg module of python

╄→гoц情女王★ 提交于 2019-12-19 04:52:08

问题


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.


回答1:


It can't work on Linux.

_winreg - Windows registry access

Availability: Windows.

New in version 2.0. These functions expose the Windows registry API to Python. Instead of using an integer as the registry handle, a handle object is used to ensure that the handles are closed correctly, even if the programmer neglects to explicitly close them.

This module exposes a very low-level interface to the Windows registry; it is expected that in the future a new winreg module will be created offering a higher-level interface to the registry API.

source: http://docs.python.org/release/2.1.2/lib/module--winreg.html




回答2:


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



来源:https://stackoverflow.com/questions/11133506/importerror-while-importing-winreg-module-of-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!