2

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
Ree
  • 129
  • 3
  • 5
  • 9
  • ...any other error messages? Have you tried to find a prebuilt version for your OS? – nneonneo Dec 21 '14 at 13:55
  • No.. how is that ? Any other option to print the output in table format using python 3.4 ? – Ree Dec 21 '14 at 14:29
  • `vcvarsall.bat` is a Microsoft C++ compiler. The error means that `setuptools` can't find a compiler installed on your machine. Normally, I find a Windows binary and use [this command](http://stackoverflow.com/a/11711878/1394393), but without an existing Windows binary, you might have to build from source yourself. – jpmc26 Dec 21 '14 at 15:14
  • Hang on. It looks like the native dependency might be `lxml`. If so, the error comes from installing `lxml`, *not* `python-docx`. What happens if you install `lxml` from [here](http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml) using the command I mentioned above before installing `python-docx`? – jpmc26 Dec 21 '14 at 15:19
  • Possible dupe of [error: Unable to find vcvarsall.bat](http://stackoverflow.com/q/2817869) – Martijn Pieters Dec 21 '14 at 16:06

6 Answers6

14

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

scanny
  • 26,423
  • 5
  • 54
  • 80
  • 1
    Since this worked for you, please accept the answer and click the up-arrow to endorse it if it was a help :) – scanny Dec 22 '14 at 12:10
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.

Alex Nies
  • 191
  • 1
  • 6
  • When trying to install either the 32-bit or the 64-bit version of the .whl files with pip in Windows 10 I get an error message saying that the .whl **is not a supported wheel on this platform.** – Benjamin May 14 '20 at 10:30
0
  1. Download the py-docx module from the official website: https://pypi.python.org/pypi/python-docx

  2. Unzip it

  3. Open the command prompt and change your directory to the unzipped file. There a file named setup.py will be present.

  4. Type the following code in the command prompt window.

    setup.py install    
    
  5. The docx module is installed.
Syler
  • 15
  • 6
0

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

0

This worked fro me:

pip uninstall docx
pip uninstall lxml
pip install lxml
pip install python-docx

following this git-hub discussion

QT-1
  • 900
  • 14
  • 21
0

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
Mark K
  • 8,767
  • 14
  • 58
  • 118