2012-08-24 34 views
1

系統默認的Python是:我通過brew安裝了python 2.7.3,但virtualenv總是使用2.7.1,爲什麼?

$ /usr/bin/python --version 
Python 2.7.1 

$PATH

export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin 

我通過homebrew安裝python 2.7.3

$ brew install python --universal --framework 

,並將其鏈接,

$ cd /System/Library/Frameworks/Python.framework/Versions 
$ sudo mv Current _Current 
$ sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/Current 

,但是當我做一個virtualenv中,它仍然2.7.1

$ python --version 
Python 2.7.3 

$ virtualenv venv 
$ cd venv;source bin/activate 
(venv) $ python --version 
Python 2.7.1 

如何解決呢?

+2

你需要使用virtualenv的'-p'標誌。請參閱http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv – Ghopper21

+0

(或使用python 2.7.3安裝virtualenv,將其添加到/ opt) – geoffspear

+0

「哪個virtualenv'和'哪個python'? – astrofrog

回答

0

從virtualenv中的幫助信息:

-p PYTHON_EXE, --python=PYTHON_EXE 
         The Python interpreter to use, e.g., 
         --python=python2.5 will use the python2.5 interpreter 
         to create the new environment. The default is the 
         interpreter that virtualenv was installed with 

你可能安裝的virtualenv與Python 2.7.1和它的作品爲設計。您可以使用-p選項在您的虛擬環境中使用另一個版本。

相關問題