关于python:ImportError:没有名为pywin32的模块

ImportError: No module named pywin32

我都尝试过

1
pip install pypiwin32

1
pip install pywin32

,它们都在我的Windows 7 x64 / Python 2.7.15 64位(这是我在PC上安装的唯一Python)上成功实现了。我什至做到了:

1
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


解决方案的确是

1
import win32api

而不是import pywin32


我只是把这个放在这里,以防有人感兴趣。这是M.Hammond和A.Robinson编写的《 Win32上的Python编程:Windows程序员的帮助》一书的摘录,其中列出了Pywin32包(或以前称为win32all包)中的模块:

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年出版,因此内容可能有点过时。