Attempting to install python-docx (error: Unable to find vcvarsall.bat)

橙三吉。 提交于 2019-12-22 10:08:21

问题


I have tried everything and I have no idea where to go from here. When I call the command pip install python-docx I get this:

    running build_ext
building 'lxml.etree' extension
error: Unable to find vcvarsall.bat

----------------------------------------
Command "c:\users\alex\appdata\local\programs\python\python35-32\python.exe -c "import setuptools, tokenize;__file__='C:\\Users\\Alex\\AppData\\Local\\Temp\\pip-build-u2i_l872\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\Alex\AppData\Local\Temp\pip-26nq6ot7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Alex\AppData\Local\Temp\pip-build-u2i_l872\lxml

at the end.

I have tried locating vsvarsall.bat and setting the path. I can't seem to find it in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools and there is no tool folder in C:\Program Files\Microsoft Visual Studio 12.0\Common7. I'm on 64bit Windows 10 and python 3.5.1.


回答1:


This is a pretty common issue people run into with Python modules. You can read up more on it here

What you can do is install a precompiled version of lxml, which is a module that python-docx relies upon. You can identify this requirement by looking at the error message, or by looking at the python-docx github page here, which lists all requirements for python-docx.

Luckily, Christoph Golke provides some precompiled modules for us, available here. <--- Hotlink that, you'll use it quite often.

Download and install the lxml module first from Christoph Golke, then try rerunning your pip install.




回答2:


I had the same issue.

After countless tries to install the right Visual C++ compilers and setting the Variables, I got one step further but it still didn't compile. I suggest to follow the other answer's advice and install a precompiled version of lxml. After doing than, I could pip install python-docx without a problem.

Keep in mind that I had to use the WinPython Control Panel to install the downloaded .exe!

More information here: Cannot install lxml on windows, fatal error C1083: Cannot open include file: 'libxml/xmlversion.h'



来源:https://stackoverflow.com/questions/34535703/attempting-to-install-python-docx-error-unable-to-find-vcvarsall-bat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!