pip install getch:clang错误

时间:2016-04-19 09:47:46

标签: python python-2.7 pip getch

我正在尝试通过pip安装getch,我有一个clang错误:

python -m pip install getch
Collecting getch
  Using cached getch-1.0.tar.gz
Installing collected packages: getch
  Running setup.py install for getch ... error
    Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-uEGRgA-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'getch' extension
    creating build
    creating build/temp.macosx-10.10-x86_64-2.7
    clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/include -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c getchmodule.c -o build/temp.macosx-10.10-x86_64-2.7/getchmodule.o
    getchmodule.c:36:6: warning: unused variable 'ok' [-Wunused-variable]
            int ok = PyArg_ParseTuple(args, "");
                ^
    getchmodule.c:43:6: warning: unused variable 'ok' [-Wunused-variable]
            int ok = PyArg_ParseTuple(args, "");
                ^
    getchmodule.c:55:4: error: use of undeclared identifier 'PyModuleDef_HEAD_INIT'
       PyModuleDef_HEAD_INIT,
       ^
    getchmodule.c:54:27: error: variable has incomplete type 'struct PyModuleDef'
    static struct PyModuleDef getchmodule = {
                              ^
    getchmodule.c:54:15: note: forward declaration of 'struct PyModuleDef'
    static struct PyModuleDef getchmodule = {
                  ^
    getchmodule.c:64:9: warning: implicit declaration of function 'PyModule_Create' is invalid in C99 [-Wimplicit-function-declaration]
            return PyModule_Create(&getchmodule);
                   ^
    3 warnings and 2 errors generated.
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-uEGRgA-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/qm/gj1n93fd7rg8rgz1ldq19gm80000gn/T/pip-build-RYKX8n/getch/

我正在使用Mac,因此无法使用msvcrt。

感谢您的帮助。

1 个答案:

答案 0 :(得分:11)

安装失败,因为它正在寻找python3标头。查看https://pypi.python.org/pypi/getch,列出了两个源分发getch-1.0-python2.tar.gzgetch-1.0.tar.gz

对于python 2,你需要前者,但看起来后者正在被选中(同样的事情发生在我身上)。我不确定pip是否应该知道如何选择正确的pip,但您可以手动选择:

复制链接,

pip install https://pypi.python.org/packages/source/g/getch/getch-1.0-python2.tar.gz#md5=586ea0f1f16aa094ff6a30736ba03c50

适合我