我基本上与 Python 2.7 中描述的情况完全相同
,系统、PIP 和 Virtualenv 仍在使用 2.6 - 如何将它们切换为使用 2.7
也就是说,我的 mac 默认使用 Python 2.7,而 Pip 安装到 2.6
我按照Ned Deily 的回答,用我的默认 Python 安装了 easy_install,并用它来安装 Pip。
现在我得到:
$ which easy_install
/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install
$ which pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
好吧,看起来不错。但是,我也得到了这个:
$ pip --version
pip 1.0.2 from /Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg (python 2.6)
并且 Pip仍在安装到 2.6。
我错过了什么?
更新:
也许这是一个线索 - 我刚刚运行了以下内容:
$ ls -la /usr/bin/python*
-rwxr-xr-x 2 root wheel 86000 May 4 2011 /usr/bin/python
-rwxr-xr-x 5 root wheel 925 May 4 2011 /usr/bin/python-config lrwxr-xr-x 1 root wheel 75 May 4 2011 /usr/bin/python2.5 ->
../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
lrwxr-xr-x 1 root wheel 82 May 4 2011
/usr/bin/python2.5-config ->
../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5-config
lrwxr-xr-x 1 root wheel 75 May 4 2011 /usr/bin/python2.6 ->
../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x 1 root wheel 82 May 4 2011
/usr/bin/python2.6-config ->
../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
-rwxr-xr-x 2 root wheel 86000 May 4 2011 /usr/bin/pythonw lrwxr-xr-x 1 root wheel 76 May 4 2011 /usr/bin/pythonw2.5 ->
../../System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5
lrwxr-xr-x 1 root wheel 76 May 4 2011 /usr/bin/pythonw2.6 ->
../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
和
$ ls -la /usr/local/bin/python*
lrwxr-xr-x 1 ykessler wheel 68
Nov 14 2011 /usr/local/bin/python ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x 1 ykessler wheel 71 Nov 14 2011
/usr/local/bin/python-32 ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python-32
lrwxr-xr-x 1 ykessler wheel 75 Nov 14 2011
/usr/local/bin/python-config ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
lrwxr-xr-x 1 ykessler wheel 71 Nov 14 2011
/usr/local/bin/python2.7 ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x 1 ykessler wheel 74 Nov 14 2011
/usr/local/bin/python2.7-32 ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-32
lrwxr-xr-x 1 ykessler wheel 78 Nov 14 2011
/usr/local/bin/python2.7-config ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x 1 ykessler wheel 69 Nov 14 2011 /usr/local/bin/pythonw
-> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw
lrwxr-xr-x 1 ykessler wheel 72 Nov 14 2011
/usr/local/bin/pythonw-32 ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw-32
lrwxr-xr-x 1 ykessler wheel 72 Nov 14 2011
/usr/local/bin/pythonw2.7 ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x 1 ykessler wheel 75 Nov 14 2011
/usr/local/bin/pythonw2.7-32 ->
../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7-32
所以看起来我的用户环境指向 2.7,但根环境指向 2.6?我该如何调和这两者?
更新 2:
好的,只是稍微转动一下螺丝:
$ sudo pip --version
pip 1.2.1 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg (python 2.7)
$ pip --version
pip 1.0.2 from /Library/Python/2.6/site-packages/pip-1.0.2-py2.6.egg (python 2.6)
所以我的根指向 2.6 但sudo pip --version
指向 pip 2.7,而我的本地用户指向 2.7 但pip --version
指向 pip 2.6
???我的大脑开始发麻。
现在我刚刚做了sudo pip install {module}
,它在 2.7 中正确安装,但我希望我知道发生了什么......
更新 3:回答 Ned 的问题:
$ type pip
pip is /Library/Frameworks/Python.framework/Versions/2.7/bin/pip
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
$ which pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
$ ls -l $(which pip)
-rwxr-xr-x 1 ykessler admin 358 Oct 3 15:30 /Library/Frameworks/Python.framework/Versions/2.7/bin/pip
$ sudo bash
bash-3.2# type pip
pip is /Library/Frameworks/Python.framework/Versions/2.7/bin/pip
bash-3.2# echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
bash-3.2# ls -l $(which pip)
-rwxr-xr-x 1 ykessler admin 358 Oct 3 15:30 /Library/Frameworks/Python.framework/Versions/2.7/bin/pip