Python 通过 pip 安装 lxml 时出错:需要 Microsoft Visual C++ 14.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38949519/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error while installing lxml through pip: Microsoft Visual C++ 14.0 is required
提问by Zeokav
I am on a windows 10 machine and recently moved from python 2.7 to 3.5. When trying to install lxml through pip, it stops and throws this error message-
我在 Windows 10 机器上,最近从 python 2.7 迁移到 3.5。尝试通过 pip 安装 lxml 时,它会停止并抛出此错误消息 -
building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
构建“lxml.etree”扩展
错误:需要 Microsoft Visual C++ 14.0。使用“Microsoft Visual C++ 构建工具”获取它:http: //landinghub.visualstudio.com/visual-cpp-build-tools
I have a working copy of VS 2015 installed. When I try to install the visual cpp tools through that link, it says that Microsoft Visual Studio 2015 is already installed on the machine. I also tried installing visual studio c++ 2015 redistributables, both 64 and 32 bit versions, but both of them say that there's another version of the product already installed.
typing set in the command prompt includes this -
我安装了 VS 2015 的工作副本。当我尝试通过该链接安装 Visual cpp 工具时,它说机器上已经安装了 Microsoft Visual Studio 2015。我还尝试安装 64 位和 32 位版本的 Visual Studio c++ 2015 可再发行组件,但他们都说已经安装了该产品的另一个版本。
在命令提示符中输入 set 包括这个 -
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
Which means that the path is set.
This is probably the only resource I could find on SO, but the answer suggests rolling back to Python 3.4.3 from 3.5. Has anybody resolved problems of this kind?
Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
EDIT: I managed to install it using the precompiled binary (Thanks Paul), but I would still like to know what's causing this.
这意味着设置了路径。
这可能是我能在 SO 上找到的唯一资源,但答案建议从 3.5 回滚到 Python 3.4.3。有没有人解决过此类问题?
需要 Microsoft Visual C++ 14.0(无法找到 vcvarsall.bat)
编辑:我设法使用预编译的二进制文件安装了它(感谢 Paul),但我仍然想知道是什么导致了这种情况。
回答by davidsheldon
Have you checked that when you installed Visual Studio, you installed the C++ compiler? It seems like a silly question, but this is the mistake I made. Check by going into the setup for visual studio (Programs and features: Modify "Visual Studio 2015"), then under Programming Languages->VC++
, make sure it's ticked.
您是否检查过安装 Visual Studio 时是否安装了 C++ 编译器?这似乎是一个愚蠢的问题,但这是我犯的错误。通过进入 Visual Studio 的设置(程序和功能:修改“Visual Studio 2015”)进行检查,然后在 下Programming Languages->VC++
,确保它已打勾。
回答by Chris Leung
- Run
pip install wheel
- Download lxmlfrom http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml, if your python version is 3.5 , download
lxml-3.6.4-cp35-cp35m-win32.whl
. - Run
python -m pip install lxml-3.6.4-cp35-cp35m-win32.whl
- 跑
pip install wheel
- 从http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml下载lxml,如果您的 python 版本是 3.5,请下载.
lxml-3.6.4-cp35-cp35m-win32.whl
- 跑
python -m pip install lxml-3.6.4-cp35-cp35m-win32.whl
回答by Eric G
As an update to the answer from @davidsheldon above, if you want to use Visual Studio Build Tools 2017 instead of 2015, it will work.
作为上面@davidsheldon 答案的更新,如果您想使用 Visual Studio Build Tools 2017 而不是 2015,它会起作用。
I found that the default install of the build tools stand alone was not enough, however, I added `VC++ 2015.3 ... toolset for desktop (x86,x64) and then python was happy:
我发现单独安装构建工具的默认安装是不够的,但是,我添加了`VC++ 2015.3 ...桌面工具集(x86,x64),然后python很高兴:
回答by Vingt Cent
I've found another solution to get through this: Because I use anaconda python, so I use this code:
我找到了另一个解决方案来解决这个问题:因为我使用 anaconda python,所以我使用以下代码:
conda install -c conda-forge scrapy
回答by Undo
I have same question with you! I found a way no need install vs2015,maybe,you just haven't install twisted.http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted.download twisted --version(Twisted?17.5.0?cp36?cp36m?win_amd64.whl)(maybe win_amd32.whl if 64didn't work),and run : pip PATH + filename
我和你有同样的问题!我找到了一种不需要安装 vs2015 的方法,也许,你只是没有安装扭曲。http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted.downloadtwisted --version(Twisted?17.5.0?cp36?cp36m?win_amd64.whl)(如果64不工作,可能是win_amd32.whl ),然后运行:pip PATH + filename
pip install C:\Users\CR\Downloads\Twisted-17.5.0-cp36-cp36m-win_amd64.whl
pip install Scrapy
I just install successful! good luck for you!
我刚刚安装成功!祝你好运!
my step to insatll scrapy: 1.pip install wheel 2.pip install lxml 3.pip install pyOpenSSL 4.pip install Twisted (fault->do like above) 5.install pywin32 form : https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/6.pip Scrapy (succesful)
我安装srapy的步骤: 1.pip install wheel 2.pip install lxml 3.pip install pyOpenSSL 4.pip install Twisted (fault->do like above) 5.install pywin32 form:https://sourceforge.net/projects/ pywin32/files/pywin32/Build%20220/6.pip Scrapy(成功)
回答by CPhelefu
Had the same problem and noticed that I had installed the 32bit version in a 64bit machine. All I did was uninstall the wrong one and install the right version and it worked fine.
有同样的问题,并注意到我在 64 位机器上安装了 32 位版本。我所做的只是卸载了错误的版本并安装了正确的版本,并且运行良好。
回答by pejaming
First:
第一的:
pip install wheel
Second: go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxmland download proper wheel.
第二:到http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml下载合适的轮子。
pip install
the file you downloaded (.whl).
pip install
您下载的文件 (.whl)。