在windows下使用pip安装python包遇到缺失stdint.h文件的错误

今天在windows上使用pip安装一个python包python-lzf时遇到如下的错误:

fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory
  error: command 'C:\\Users\\wxyuan\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

从错误提示可以看出,是由于缺少了stdint.h造成的错误,经过一番搜索找到了解决方法,如下:
(1). 从这里https://www.microsoft.com/download/details.aspx?id=44266下载软件Microsoft Visual C++ Compiler for Python 2.7(事实上该软件我已经安装了)
(2). 确认安装路径,比如我的安装路径是C:\Users\wxyuan\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
(3). 下载stdint.h文件,下载地址https://github.com/mattn/gntp-send/blob/master/include/msinttypes/stdint.h
(4). 拷贝stdint.h文件到安装路径的VC\include目录下,比如我的路径是C:\Users\wxyuan\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include

最后重新安装python-lzf包,成功!

关于为什么安装的Microsoft Visual C++ Compiler for Python 2.7缺少了stdint.h文件,这篇文章有介绍http://stephendoyle.blogspot.com/2008/03/c-tr1-stdinth-still-missing-from-visual.html

猜你喜欢

转载自www.cnblogs.com/wxyidea/p/10317020.html