问题
I need to create table in a Word document through Python 3.4. For that, I am trying to install python-docx
in Windows. If I use pip install python-docx
I am getting the following error:
vcvarsall.bat error
So I installed Visual Studio and then tried to install it and I am still getting the following :
error: Setup script exited with error: command '"C:\Program Files (x86)\Microsoft Visual
Studio 10.0\VC\BIN\cl.exe"' failed with exit status 2
回答1:
This is a problem with the lxml
install. If you install lxml
separately, using a Windows binary package, then reinstall python-docx, this error should go away.
You can find a binary lxml
package here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
回答2:
I had the same issue. I was not able to install the lxml wheel for 64 machine because python falsely identifies my computer as 32. Ultimately installed the 32 and then it installed python-docx successfully. FYI: I would have added this to comments but I don’t have the 50 required reputation to do so.
回答3:
Download the py-docx module from the official website: https://pypi.python.org/pypi/python-docx
Unzip it
Open the command prompt and change your directory to the unzipped file. There a file named setup.py will be present.
Type the following code in the command prompt window.
setup.py install
- The docx module is installed.
回答4:
In cas somebody is still struggling with this topic in version 3.7: https://visualstudio.microsoft.com/pl/downloads/ Scroll down and install: Build Tools for Visual Studio 2017
回答5:
This worked fro me:
pip uninstall docx
pip uninstall lxml
pip install lxml
pip install python-docx
following this git-hub discussion
回答6:
Or, just download the .whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml as @scanny mentioned, then use pip to install it:
CMD environment:
C:\Python27\Scripts>pip install C:\Python27\Scripts\python_docx-0.8.10-py2.py3-none-any.whl
来源:https://stackoverflow.com/questions/27589971/unable-to-install-python-docx