无法使用C编译python包。错误2 - 无法打开包含文件:'alloca.h'?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法使用C编译python包。错误2 - 无法打开包含文件:'alloca.h'?相关的知识,希望对你有一定的参考价值。

这一切都始于“无法找到vcvarsall.bat”但我很快修复了它。之后我无法解决一些“错误2”。

已经尝试过的说明herehere

  • 安装Visual C ++编译器Python 2.7
  • 安装了Microsoft Visual Studio 2008 Express Edition SP1
  • 已安装适用于Windows 7和.NET Framework 3.5 SP1的Windows SDK
  • 操纵vcvarsall.bat和vsvars64

但仍然无法安装pyethash,PyYAML,scrypt。 pyethash的详细信息如下。

试图安装Crypto,它也使用C ++库 - 它的工作原理。是否仍然看起来我有编译器问题或者我应该在其他地方看看?

使用Windows 8.1 x64,python 2.7.11(v2.7.11:6d1b6a68f775,2015年12月5日,20:40:30)[MSC v.1500 64 bit(AMD64)]

Installing with pip

PS C:pyethereumethash-master> pip install pyethash
Collecting pyethash
  Using cached pyethash-0.1.27.tar.gz
Building wheels for collected packages: pyethash
  Running setup.py bdist_wheel for pyethash ... error
  Complete output from command c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:\users\b19a~1\ap
pdata\local\temp\pip-build-y2vsbx\pyethash\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().
replace('
', '
'), __file__, 'exec'))" bdist_wheel -d c:users19a~1appdatalocal	emp	mpwmonvkpip-wheel- --pytho
n-tag cp27:
  running bdist_wheel
  running build
  running build_ext
  building 'pyethash' extension
  error: [Error 2]

  ----------------------------------------
  Failed building wheel for pyethash
  Running setup.py clean for pyethash
Failed to build pyethash
Installing collected packages: pyethash
  Running setup.py install for pyethash ... error
    Complete output from command c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:\users\b19a~1\
appdata\local\temp\pip-build-y2vsbx\pyethash\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('
', '
'), __file__, 'exec'))" install --record c:users19a~1appdatalocal	emppip-pvhu8d-recordinsta
ll-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pyethash' extension
    error: [Error 2]

    ----------------------------------------
Command "c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:\users\b19a~1\appdata\local\temp\pi
p-build-y2vsbx\pyethash\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('
', '
'),
 __file__, 'exec'))" install --record c:users19a~1appdatalocal	emppip-pvhu8d-recordinstall-record.txt --single-v
ersion-externally-managed --compile" failed with error code 1 in c:users19a~1appdatalocal	emppip-build-y2vsbxpyethash

Installing manually

PS C:pyethereumethash-master> python setup.py install
running install
running build
running build_ext
building 'pyethash' extension
C:Program Files (x86)Microsoft Visual Studio 9.0VCBINamd64cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:Python27include -IC:Python27PC /Tcsrc/python/core.c /Fobuild	emp.win-amd64-2.7Releasesrc/python/core.obj -Isrc/ -std=gnu99 -Wallcl : Command line warning D9002 : ignoring unknown option '-std=gnu99'core.c
c:program files (x86)microsoft visual studio 9.0vcincludecodeanalysissourceannotations.h(81) : warning C4820: 'PreAttribute' : '4' bytes padding added after data member 'Access'
c:program files (x86)microsoft visual studio 9.0vcincludecodeanalysissourceannotations.h(96) : warning C4820: 

....
....
c:python27includeimport.h(61) : warning C4820: '_frozen' : '4' bytes padding added after data member 'size'
c:python27includecode.h(26) : warning C4820: '<unnamed-tag>' : '4' bytes padding added after data member 'co_firstlineno'src/python/core.c(2) : fatal error C1083: Cannot open include file: 'alloca.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe' failed with exit status 2
答案

alloca仅在Linux中出现,这是一个关键的bug,参见https://github.com/ethereum/ethash/pull/107

以上是关于无法使用C编译python包。错误2 - 无法打开包含文件:'alloca.h'?的主要内容,如果未能解决你的问题,请参考以下文章

急!求解vc2010下opencv2.4.3编译错误 fatal error C1083: 无法打开包括文件:“opencv2/opencv.hpp”

CompileAssemblyFromSource 返回错误“编译表达式:无法打开 c:\Users\*”以读取 'c:\Users\* 不是有效的 Win32 资源文件

VS2008 编译时出现的错误:无法打开编译器中间文件。如何解决?

编译错误 /usr/bin/ld: 无法打开输出文件 bin/server: 没有这样的文件或目录

icpc 无法打开源文件“bits/c++config.h”错误

无法使用 buildozer 编译 python 脚本