【问题标题】:Cannot compile python packages using C. Error 2 - Cannot open include file: 'alloca.h'?无法使用 C 编译 python 包。错误 2 - 无法打开包含文件:'alloca.h'?
【发布时间】:2016-12-02 23:31:48
【问题描述】:

这一切都是从“无法找到 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, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)]

使用 pip 安装

PS C:\pyethereum\ethash-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:\python27\python.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('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d c:\users\b19a~1\appdata\local\temp\tmpwmonvkpip-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:\python27\python.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('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\b19a~1\appdata\local\temp\pip-pvhu8d-record\insta
ll-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pyethash' extension
    error: [Error 2]

    ----------------------------------------
Command "c:\python27\python.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('\r\n', '\n'),
 __file__, 'exec'))" install --record c:\users\b19a~1\appdata\local\temp\pip-pvhu8d-record\install-record.txt --single-v
ersion-externally-managed --compile" failed with error code 1 in c:\users\b19a~1\appdata\local\temp\pip-build-y2vsbx\pyethash\

手动安装

PS C:\pyethereum\ethash-master> python setup.py install
running install
running build
running build_ext
building 'pyethash' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tcsrc/python/core.c /Fobuild\temp.win-amd64-2.7\Release\src/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.0\vc\include\codeanalysis\sourceannotations.h(81) : warning C4820: 'PreAttribute' : '4' bytes padding added after data member 'Access'
c:\program files (x86)\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h(96) : warning C4820: 

....
....
c:\python27\include\import.h(61) : warning C4820: '_frozen' : '4' bytes padding added after data member 'size'
c:\python27\include\code.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

【问题讨论】:

    标签: python c++ windows visual-studio-2008 pip


    【解决方案1】:

    alloca 仅在 Linux 中可见 这是一个严重的错误 见https://github.com/ethereum/ethash/pull/107

    【讨论】:

    • 欢迎来到 Stack Overflow。虽然此链接可能会回答问题,但最好在此处包含 essential parts of the answer 并提供链接以供参考。如果链接页面发生更改,仅链接的答案可能会失效。
    猜你喜欢
    • 2016-12-07
    • 2015-03-19
    • 1970-01-01
    • 1970-01-01
    • 2012-09-04
    • 2016-11-29
    • 2014-12-07
    相关资源
    最近更新 更多