Search code examples
pythonpython-3.xpython-2.7pippython-docx

Error installing python-docx


Trying to install python-docx through pip for 'Learn to Automate the Boring Things with Python'. I am getting errors like this.

I have Googled up some solutions to this issue, but they don't seem to work for me, or I am not deploying the solution correctly.

One post on Stackoverflow said to download an lxml file made available by Christoph Golke.

I downloaded, and then tried 'pip install lxml', and basically got the same error message as the screenshot, telling me 'Unable to find vcvarsall.bat'.

Am I supposed to put this file in a certain directory, before executing that command? Any help would be appreciated.


Solution

  • so I found the answer to this issue.

    So I wasn't aware that to install the lxml file, you first need to change to the directory of that file, and type in the complete name of that file. Either that, or typing the path of the lxml file directly into the cmd prompt, like:

    pip install C:\Users\yourName\Downloads\lxml-3.6.4-cp35-cp35m-win32
    

    or

    cd C:\Users\yourName\Downloads
    pip install lxml-3.6.4-cp35-cp35m-win32
    

    which successfully installed the lxml file, which then led to a successful installation of the python-docx file.

    Essentially, a basic knowledge of the command prompt would've helped me avoid this problem...but hope this helps for anyone else who doesn't know what to do!