2012-05-24 144 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方法。