2012-05-24 54 views
3

我刚开始使用virtualenv,但我试图在virtualenv环境(我正在运行Windows)中安装gevent。当我使用PIP从virtualenv中,我得到这个错误:在virtualenv中安装gevent

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

封装指数有MSI的EXE文件,并安装在Windows(http://pypi.python.org/pypi/gevent/0.13.7)但我不知道如何将它们安装到virtualenv环境中(或者甚至可能)。当我尝试从virtualenv中promp 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

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:\> 

Can I install Python windows packages into virtualenvs?另一种选择是从源代码安装,你可以用PIP做到这一点,但是这需要设置编译器和环境,这是更难比上面的简单命令。

+1

它仍然以'错误结束:安装程序脚本退出请使用--libevent DIR提供libevent源的路径 – Flavien

0

从错误消息,它会出现你需要libevent源代码。我想你需要更进一步,编译/安装系统范围内的libevent,以便点可以找到它。

  1. 我会从http://libevent.org/下载最新的稳定源码开始。使用说明在自述其
  2. 编译并安装:https://github.com/libevent/libevent#readme

要编译它在Windows,你需要使用GNU风格的构建实用程序像makeautoconf。我建议http://www.mingw.org/

一旦你安装了libevent系统,我想pip会找到它并继续安装gevent

0

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

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