在virtualen中安装gevent

2024-04-28 05:52:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚开始使用virtualenv,但我正在尝试在virtualenv环境中安装gevent(我正在运行Windows)。当我使用virtualenv的PIP时,我得到以下错误:

MyEnv>pip install gevent
Downloading/unpacking gevent
  Running setup.py egg_info for package gevent
    Please provide path to libevent source with --libevent DIR

包索引包含用于在Windows上安装的MSI和EXE(http://pypi.python.org/pypi/gevent/0.13.7),但我不知道如何将它们安装到virtualenv环境中(或者如果可能的话)。当我从virtualenv promp尝试pip install gevent-0.13.7.win32-py2.7.exe时,我也会得到一个错误:

^{pr2}$

有人知道怎么做吗?在


Tags: installpippypi环境virtualenvwindows错误setup
3条回答

从错误消息中可以看出,您需要libevent源代码。我想您需要更进一步,在系统范围内编译/安装libevent,这样pip才能找到它。在

  1. 我首先从http://libevent.org/下载最新的稳定源代码。在
  2. 使用自述文件中的说明编译并安装它:https://github.com/libevent/libevent#readme

要在Windows上编译它,您需要使用GNU风格的构建工具,比如make和{}。我推荐http://www.mingw.org/。在

一旦在系统范围内安装了libevent,我想pip会找到它并继续进行gevent安装。在

在gevent-0.13.7的msi中,可以选择一个备用安装点。将其指向特定虚拟环境的根目录(就在/Lib和/Scripts所在的位置上方)。应该能正确安装。在

您还需要确保安装了greenlets。为此,您可以使用Piotr建议的方法在.exe上安装easy_。在

Pip还不支持安装二进制软件包。如果您想从二进制软件包安装,必须使用easy\u install-easy_install gevent-0.13.7.win32-py2.7.exe

Microsoft Windows XP [Wersja 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Z:\>virtualenv z:\venv\gevent-install
New python executable in z:\venv\gevent-install\Scripts\python.exe
Installing distribute..................................................................................................
............................................................................................done.
Installing pip.................done.

Z:\>venv\gevent-install\Scripts\activate
(gevent-install) Z:\>easy_install c:\python\packages\gevent-0.13.7.win32-py2.7.exe
Processing gevent-0.13.7.win32-py2.7.exe
creating 'c:\docume~1\pdobro~1\ustawi~1\temp\easy_install-b5nj3i\gevent-0.13.7-py2.7-win32.egg' and adding 'c:\docume~1
pdobro~1\ustawi~1\temp\easy_install-b5nj3i\gevent-0.13.7-py2.7-win32.egg.tmp' to it
creating z:\venv\gevent-install\lib\site-packages\gevent-0.13.7-py2.7-win32.egg
Extracting gevent-0.13.7-py2.7-win32.egg to z:\venv\gevent-install\lib\site-packages
Adding gevent 0.13.7 to easy-install.pth file

Installed z:\venv\gevent-install\lib\site-packages\gevent-0.13.7-py2.7-win32.egg
Processing dependencies for gevent==0.13.7
Searching for greenlet
Reading http://pypi.python.org/simple/greenlet/
Reading http://bitbucket.org/ambroff/greenlet
Reading https://github.com/python-greenlet/greenlet
Best match: greenlet 0.3.4
Downloading http://pypi.python.org/packages/2.7/g/greenlet/greenlet-0.3.4-py2.7-win32.egg#md5=9941aa246358c586bb274812e
130629
Processing greenlet-0.3.4-py2.7-win32.egg
creating z:\venv\gevent-install\lib\site-packages\greenlet-0.3.4-py2.7-win32.egg
Extracting greenlet-0.3.4-py2.7-win32.egg to z:\venv\gevent-install\lib\site-packages
Adding greenlet 0.3.4 to easy-install.pth file

Installed z:\venv\gevent-install\lib\site-packages\greenlet-0.3.4-py2.7-win32.egg
Finished processing dependencies for gevent==0.13.7

(gevent-install) Z:\>

另一个选择是从源代码安装,您可以用pip来完成,但这需要设置编译器和环境,这比上面的简单命令要困难得多。在

相关问题 更多 >