在虚拟环境中安装gevent

3

我刚开始使用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),但我不知道如何将它们安装到虚拟环境中(或者是否可能)。当我尝试从虚拟环境提示符中执行pip install gevent-0.13.7.win32-py2.7.exe时,也会出现错误:
ValueError: ('Expected version spec in', 'D:\\Downloads\\gevent-0.13.7.win32-py2.7.exe', 'at', ':\\Downloads\\gevent-0.13.7.win32-py2.7.exe')

有人知道如何做到这一点吗?

3个回答

3

Pip目前还不支持安装二进制包。如果您想安装二进制包,您需要使用easy_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:\>

请参考如何在虚拟环境中安装Python包? 另外一种选择是从源代码安装,您可以使用pip完成此操作,但这需要设置编译器和环境,比上面的简单命令要困难得多。


1
仍然以“error: Setup script exited with Please provide path to libevent source with --libevent DIR”结束。 - Flavien

0

从错误信息来看,似乎您需要libevent源代码。我想您需要进一步编译/安装libevent系统级别,以便pip可以找到它。

  1. 我建议您从http://libevent.org/下载最新的稳定源代码。
  2. 按照README中的说明进行编译和安装:https://github.com/libevent/libevent#readme

在Windows上编译它,您需要使用类似于makeautoconf的GNU样式构建工具。我推荐http://www.mingw.org/

一旦您已经系统范围内安装了libevent,我相信pip会找到它并继续安装gevent


0
在 gevent-0.13.7 的 msi 中,有一个选项可以选择替代的安装点。将其指向特定虚拟环境的根目录(位于 /Lib 和 /Scripts 的上方)。这样应该可以正确安装。同时需要确保已安装 greenlets。您可以使用 Piotr 建议的方法,在 .exe 上使用 easy_install 安装。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接