ImportError: No module named pywin32

ImportError: No module named pywin32

我都试过了

pip install pypiwin32

pip install pywin32

他们都在我的 Windows 7 x64 / Python 2.7.15 64 位上成功了(这是我在我的电脑上安装的唯一 Python)。我什至做了:

python C:\Python27\Scripts\pywin32_postinstall.py -install

并成功返回:

...
Shortcut to documentation created
The pywin32 extensions were successfully installed.

当我做 import pywin32 时,我仍然得到:

ImportError: No module named pywin32

如何在 Windows 7 上安装 pywin32

解决方案确实是

import win32api

而不是 import pywin32!

我只是把它放在这里以防有人感兴趣。这是 M. Hammond 和 A. Robinson 在 Pywin32 包(或之前称为 win32all 包)中列出模块的书 Python Programming On Win32: Help for Windows Programmers 中的节选:

mmapfile - Interfaces to Windows memory-mapped files, a mechanism that allows data to be shared among multiple processes.

odbc - An interface to the Open DataBase Connectivity API, a portable API for connection to multiple database.

win32api - Accesses many of the common and simple Windows APIs; a general-purpose module with a cross section of API support.

win32event - Accesses the Windows even the signaling API. This module allows you to manipulate and wait for Windows events, semaphores, mutexes, etc.

win32evtlog, win32evtlogutil - An interface to the Windows NT Event Log. The win32evtlog module provides a raw interface to the Windows NT API, while the win32evtlogutil module provides utilities to simplify working with the module.

win32pdh - An interface to the Windows NT Performance Monitor. This module uses a helper DLL provided by Microsoft known as the Performance Data Helper or PDH.

win32pipe - Accesses the pipe-related Win32 functions, such as functions for creating and using pipes, named pipes.

win32file - Accesses the file-related Win32 functions. This module exposes a low-level, raw interface to files on Windows and is used only when the standard Python file object isn't suitable.

win32lz - An interface to the Windows LZ compression library. Note that since this module was created, Python now ships with support for the gzip compression format, so in most cases win32lz is no longer used.

win32net, win32wnet - Interface to the Windows networking API. win32net provides an interface to Windows NT-specific server networking, while win32wnet provides client-networking functions available to all versions.

win32print - Interface to the printer-related Windows APIs.

win32process - Interface to the process-related Windows APIs.

win32ras - Interface to the Windows Remote Access Service (RAS). Used for establishing remote connections to Windows NT servers, typically using a modem.

win32security - Accesses the Windows NT security-related functions.

win32service, win32serviceutil - Access the Windows NT Services-related API.

win32trace, win32traceutil - Debugging related modules. These modules allow you to collect the output of a Python process in a separate process. This is most useful when debugging server-style application, where Python error and other messages are not available.

注:本书出版于2000年,内容可能有些过时