在 windows 7 64 位上安装 python-pptx 时出错

error installing python-pptx on windows 7 64 bit

我使用 python 2.7.12 和更新的 pip

我需要在 windows 7 64 位机器上安装 python-pptx,

我尝试使用 pip install python-pptx 和 get

命令"c:\python27\python.exe -u -c "import setuptools, tokenize;file='c:\users\thebea~1\appdata\local\temp\pip-build-dmvmgk\lxml\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(编译( code, file, 'exec'))" install --record c:\users\thebea~1\appdata\local\temp\pip-py7w8l-record\install-record.txt --single-version-externally-managed --compile" 失败,错误代码 1 in c:\users\thebea~1\appdata\local\temp\pip-build-dmvmgk\lxml\

当我尝试使用简易安装时 easy_install python-pptx 我得到 错误:安装脚本因错误而退出:命令 'C:\Users\thebeancounter\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python.0\VC\Bin\amd64\cl.exe' 失败,退出状态为 2

当我尝试 scipy 时它是相似的,当我安装其他软件包时它没问题,python 是 运行 并在路径

中定义

我找到 this 并为 windows 安装了 python c++ 编译器

并且并且安装了sdk

知道这里出了什么问题吗?

这是 lxml 安装的问题,python-pptx 依赖安装。因为lxml依赖于编译好的C代码,所以需要编译器才能从源码包中安装。

解决方案是安装预编译的 lxml 包,格式为 "wheel"(.whl 文件)。你可以在这里得到那些: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml。选择 "cp*" 编号与您的 Python 版本匹配的那个,例如'cp27' 对于 Python 2.7。请注意,您可能需要 32 位 lxml,因为 Windows 的默认 Python 安装可能是 32 位。

可能有更多详细信息,如果您在 'install lxml windows 7 64' 上搜索,您会找到更多资源。