加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – pip install getch:clang错误

发布时间:2020-12-20 12:10:27 所属栏目:Python 来源:网络整理
导读:我试图通过pip安装getch,我有一个clang错误: python -m pip install getchCollecting getch Using cached getch-1.0.tar.gzInstalling collected packages: getch Running setup.py install for getch ... error Complete output from command /usr/local/o
我试图通过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('rn','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,'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.

谢谢您的帮助.

解决方法

安装失败,因为它正在寻找python3标头.查看 https://pypi.python.org/pypi/getch,列出了两个源分发,getch-1.0-python2.tar.gz和getch-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

适合我

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读