Python 如何在 Windows 7 中安装 pywin32 模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4863056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 17:52:10  来源:igfitidea点击:

How to install pywin32 module in windows 7

pythonccompiler-constructionmingwpywin32

提问by narayanpatra

I am trying to install pywin32. I downloaded it from sourceforge.net. When I run

我正在尝试安装 pywin32。我是从 sourceforge.net 下载的。当我跑

setup.py install

it shows "Unable to find vcvarsall.bat". I Googled about it and found that I have to install MinGW and set path then run

它显示“无法找到 vcvarsall.bat”。我用谷歌搜索了一下,发现我必须安装 MinGW 并设置路径然后运行

python setup.py build --compiler=mingw32

but it's showing

但它显示

Can't find a version in Windows.h

Can anybody help? (I have a trial version of Visual Studio 2010 Ultimate installed and MinGW C and C++ compiler installed. Operating system: Windows 7.)

有人可以帮忙吗?(我安装了 Visual Studio 2010 Ultimate 试用版并安装了 MinGW C 和 C++ 编译器。操作系统:Windows 7。)

Can anybody tell me a source from where I can download Python binaries already compiled in MinGW, so I don't have to do all this. Or if I can get a python which already have Windows modules.

谁能告诉我从哪里可以下载已在 MinGW 中编译的 Python 二进制文件的来源,这样我就不必做所有这些了。或者如果我能得到一个已经有 Windows 模块的 python。

采纳答案by Corey Goldberg

are you just trying to install it, or are you looking to build from source?

你只是想安装它,还是想从源代码构建?

If you just need to install, the easiest way is to use the MSI installers provided here:

如果您只需要安装,最简单的方法是使用此处提供的 MSI 安装程序:

http://sourceforge.net/projects/pywin32/files/pywin32/(for updated versions)

http://sourceforge.net/projects/pywin32/files/pywin32/(更新版本)

make sure you get the correct version (matches Python version, 32bit/64bit, etc)

确保您获得正确的版本(匹配 Python 版本、32 位/64 位等)

回答by Vorac

I had the exact same problem. The problem was that Anaconda had not registered Python in the windows registry.

我有同样的问题。问题是 Anaconda 没有在 Windows 注册表中注册 Python。

1) pip install pywin
2) execute this scriptto register Python in the windows registry
3) download the appropriate package form Corey Goldberg's answer and python will be detected

1) pip install pywin
2) 执行此脚本以在 windows 注册表中注册 Python
3) 从Corey Goldberg的答案中下载相应的包,然后将检测到 python

回答by jpmc26

I disagree with the accepted answerbeing "the easiest", particularly if you want to use virtualenv.

我不同意接受的答案是“最简单的”,特别是如果您想使用 virtualenv。

You can use the Unofficial Windows Binariesinstead. Download the appropriate wheel from there, and install it with pip:

您可以改用非官方的 Windows 二进制文件。从那里下载适当的轮子,并使用以下命令安装它pip

pip install pywin32-219-cp27-none-win32.whl

(Make sure you pick the one for the right version and bitness of Python).

(确保您选择了适合 Python 版本和位数的那个)。

You might be able to get the URL and install it via pipwithout downloading it first, but they're made it a bit harder to just grab the URL. Probably better to download it and host it somewhere yourself.

您也许可以获取 URL 并通过pip它安装,而无需先下载它,但它们使获取 URL 变得有点困难。可能最好下载它并将其托管在自己的某个地方。

回答by Kanguros

You can install pywin32 wheel packages from PYPI with PIP by pointing to this package: https://pypi.python.org/pypi/pypiwin32No need to worry about first downloading the package, just use pip:

你可以通过指向这个包,从PYPI with PIP安装pywin32轮包:https://pypi.python.org/pypi/pypiwin32不用担心先下载包,直接使用pip即可:

pip install pypiwin32

Currently I think this is "the easiest" way to get in working :) Hope this helps.

目前我认为这是开始工作的“最简单”方式:) 希望这会有所帮助。

回答by Mark Amery

Quoting the README at https://github.com/mhammond/pywin32:

引用https://github.com/mhammond/pywin32 上的自述文件:

By far the easiest way to use pywin32 is to grab binaries from the most recent release

到目前为止,使用 pywin32 的最简单方法是从最新版本中获取二进制文件

Just download the installer for your version of Python from https://github.com/mhammond/pywin32/releasesand run it, and you're done.

只需从https://github.com/mhammond/pywin32/releases下载适用于您的 Python 版本的安装程序并运行它,您就完成了。