我无法安装 Gevent

Posted

技术标签:

【中文标题】我无法安装 Gevent【英文标题】:I can't install Gevent 【发布时间】:2015-04-09 12:54:50 【问题描述】:

我需要为 python2.7 安装 Gevent,但是在尝试了几乎所有之后我仍然没有安装它。 我有python 2.6.6,这里一切正常......但我需要python2.7+然后我安装python 2.7.9,现在只有问题...... 在我的项目的某些部分在 python 2.6 中工作之前,可以,但现在我的项目不能在 2.6 和 2.7 上运行,不知道为什么它停止使用 2.6 但 nvm 我需要使用 2.7 但是....我无法安装 gevent,我已经安装了 libevent-devel 一个 greenlet 但我不能安装 gevent

# pip2.7 install gevent
Collecting gevent
  Using cached gevent-1.0.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): greenlet in /usr/local/lib/python2.7/site-packages (from gevent)
Installing collected packages: gevent
  Running setup.py install for gevent
    configure: error: in `/tmp/pip-build-fpnLvN/gevent/build/temp.linux-x86_64-2.7/libev':
    configure: error: cannot run C compiled programs.
    If you meant to cross compile, use `--host'.
    See `config.log' for more details
    Running '/bin/sh /tmp/pip-build-fpnLvN/gevent/libev/configure > configure-output.txt' in /tmp/pip-build-fpnLvN/gevent/build/temp.linux-x86_64-2.7/libev
    building 'gevent.core' extension
    ccache gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -Ibuild/temp.linux-x86_64-2.7/libev -Ilibev -I/usr/local/include/python2.7 -c gevent/gevent.core.c -o build/temp.linux-x86_64-2.7/gevent/gevent.core.o
    In file included from gevent/libev.h:2,
                     from gevent/gevent.core.c:313:
    libev/ev.c:45:22: error: config.h: No such file or directory
    libev/ev.c:477:48: warning: "/*" within comment
    In file included from gevent/libev.h:2,
                     from gevent/gevent.core.c:313:
    libev/ev.c:1531: warning: ‘ev_default_loop_ptr’ initialized and declared ‘extern’
    In file included from gevent/libev.h:2,
                     from gevent/gevent.core.c:313:
    libev/ev.c: In function ‘ev_io_start’:
    libev/ev.c:3554: warning: suggest parentheses around arithmetic in operand of ‘|’
    libev/ev.c:4795:27: warning: "/*" within comment
    libev/ev.c:4796:27: warning: "/*" within comment
    error: command 'ccache' failed with exit status 1
    Complete output from command /usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-fpnLvN/gevent/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ruy7Xb-record/install-record.txt --single-version-externally-managed --compile:
    running install

    running build

    running build_py

    creating build

    creating build/lib.linux-x86_64-2.7

    creating build/lib.linux-x86_64-2.7/gevent

    copying gevent/resolver_thread.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/socket.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/threadpool.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/util.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/__init__.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/monkey.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/queue.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/coros.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/server.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/_threading.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/thread.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/select.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/hub.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/fileobject.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/wsgi.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/pywsgi.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/event.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/greenlet.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/ssl.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/local.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/subprocess.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/threading.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/os.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/win32util.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/baseserver.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/lock.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/backdoor.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/pool.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/resolver_ares.py -> build/lib.linux-x86_64-2.7/gevent

    copying gevent/timeout.py -> build/lib.linux-x86_64-2.7/gevent

    running build_ext

    configure: error: in `/tmp/pip-build-fpnLvN/gevent/build/temp.linux-x86_64-2.7/libev':

    configure: error: cannot run C compiled programs.

    If you meant to cross compile, use `--host'.

    See `config.log' for more details

    Running '/bin/sh /tmp/pip-build-fpnLvN/gevent/libev/configure > configure-output.txt' in /tmp/pip-build-fpnLvN/gevent/build/temp.linux-x86_64-2.7/libev

    building 'gevent.core' extension

    creating build/temp.linux-x86_64-2.7/gevent

    ccache gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -DLIBEV_EMBED=1 -DEV_COMMON= -DEV_CLEANUP_ENABLE=0 -DEV_EMBED_ENABLE=0 -DEV_PERIODIC_ENABLE=0 -Ibuild/temp.linux-x86_64-2.7/libev -Ilibev -I/usr/local/include/python2.7 -c gevent/gevent.core.c -o build/temp.linux-x86_64-2.7/gevent/gevent.core.o

    In file included from gevent/libev.h:2,

                     from gevent/gevent.core.c:313:

    libev/ev.c:45:22: error: config.h: No such file or directory

    libev/ev.c:477:48: warning: "/*" within comment

    In file included from gevent/libev.h:2,

                     from gevent/gevent.core.c:313:

    libev/ev.c:1531: warning: ‘ev_default_loop_ptr’ initialized and declared ‘extern’

    In file included from gevent/libev.h:2,

                     from gevent/gevent.core.c:313:

    libev/ev.c: In function ‘ev_io_start’:

    libev/ev.c:3554: warning: suggest parentheses around arithmetic in operand of ‘|’

    libev/ev.c:4795:27: warning: "/*" within comment

    libev/ev.c:4796:27: warning: "/*" within comment

    error: command 'ccache' failed with exit status 1

    ----------------------------------------
    Command "/usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip-build-fpnLvN/gevent/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Ruy7Xb-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-fpnLvN/gevent

【问题讨论】:

您似乎在使用ccache。尝试 not 使用ccache 而只是简单的cc...这可能是您的问题。如果不是,请分享您的config.log(使用cc,而不是ccache)。 @Carpetsmoker 我该怎么做? 我的 python config.log -> 37.233.101.14/config.log 好吧,ccache 是您或某人手动启用的。您可能在某处的某个 shell 启动脚本中设置了 CC 环境变量...您可以尝试在运行 pip install 之前将 CC 设置为 gcc,如下所示:env CC=gcc pip install gevent 我尝试使用 gcc 但它没有帮助link 【参考方案1】:

我的问题有解决方案enter link description here

这可能是最重要的(代替python2.X 输入您的python 版本。例如python2.7export PYTHONPATH=$HOME/.local/lib/python/site-packages:$PYTHONPATHexport PYTHONPATH=$HOME/.local/lib/python2.X/site-packages:$PYTHONPATHexport PATH=$HOME/.local/bin:$PATH

【讨论】:

【参考方案2】:

安装这个对我有用,

sudo apt-get install libevent-dev
sudo apt-get install python-all-dev

然后,

pip install greenlet
pip install gevent

【讨论】:

在谷歌上搜索了两个小时,发现这个......工作! +1 我可以安装 gevent 但在虚拟环境中找不到。【参考方案3】:

它对我有用。首先从 Pipfile.lock 中移除 gevent

"gevent": 
        "hashes": [
            "sha256:004cdbc6c18b4076acfa256c1794abf87bf9b97e0cfd4136f5098535c4b4132e",
            "sha256:3ae1ca0f533ddcb17aab16ce66b424b3f3b855ff3b9508526915d3c6b73fba31",
            "sha256:704a048005e6389fcb8276113bb9e7d0a3160bc382b9bcc629e398a43645de5c",
            "sha256:80ee22c28dae6dc70c7e4385f0d0292da9eebccf14b90620a32f10d71797838e",
            "sha256:aa224957cbbc028bbdfbec89625c7efa66bb8ddb845ed2fe323bd6b24e919dcf",
            "sha256:f3e8656f0b7bce355f14896d0b644c0a91e01fa12d9d65e6b09faad1d2c06e65"
        ],
        "index": "pypi",
        "version": "==1.0.2"

然后手动安装geventpipenv install gevent

希望它对你有用。

【讨论】:

【参考方案4】:

此外: sudo apt-get install libevent-dev sudo apt-get install python-all-dev

我还需要安装(我使用python3)来解决类似的问题 sudo apt-get install python3-dev

【讨论】:

【参考方案5】:

我尝试安装一些其他答案所描述的其他软件包,所以不确定是否有任何帮助,但最终让它工作的是使用easy_install而不是pip

easy_install gevent

【讨论】:

【参考方案6】:

我在尝试安装 gevent-websocket 0.10.1 时遇到了错误,但是当我安装了 greenlet 后问题就解决了:

pip3 install greenlet

先,然后:

pip3 install gevent-websocket

【讨论】:

【参考方案7】:

我设法通过使用已编译的二进制文件而不是 pip 在我的树莓派零上解决了同样的问题。

sudo apt-get install python-gevent

【讨论】:

【参考方案8】:

有一个类似的问题,升级 pip 与

pip install --upgrade pip

为我工作。确保您拥有最新版本。就我而言,我假设创建一个新的虚拟环境会自动提供最新版本,但我错了。

【讨论】:

这对我有用!

以上是关于我无法安装 Gevent的主要内容,如果未能解决你的问题,请参考以下文章

无法在安装了 gevent 的情况下运行 Flask 应用程序

错误:无法为 gevent 构建***,这是安装基于 pyproject.toml 的项目所必需的

WebSocket 传输不可用。安装 eventlet 或 gevent 和 gevent-websocket 以提高性能

python.h 在尝试安装 gevent-socketio 时不喜欢

windonw10 ,python3.7安装gevent

windows下安装gevent