Lion上实际安装了太多的Python

Lion上实际安装了太多的Python

本文介绍了在OSX Mountain Lion上实际安装了太多的Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以下位置使用了三个不同的Python 2.7:

I have three different Python 2.7s at:

/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

我使用了许多来自不同来源的软件包.我目前正在从端口(MacPorts), easy_install pip (由 easy_install 安装)和Mercurial安装软件包.还有一些我必须从映像安装或从源代码构建.我对这些有更多的控制权.

I use a number of packages that come from different sources. I am currently installing packages from port (MacPorts), easy_install, pip (installed by easy_install), and Mercurial. There are also some that I have to install from image or build from source. I have more control over those.

问题在于easy_install和pip似乎正在安装到一个位置(/Library/Frameworks/...),而MacPorts安装到另一个位置(/opt/local/Library/Frameworks/...).

The problem is that easy_install and pip seem to be installing to one location (/Library/Frameworks/...) and MacPorts installs to another (/opt/local/Library/Frameworks/...).

我现在最好的行动是什么?删除/Library/Frameworks/.../python2.7并将easy_install和pip移至/opt/local/...上的MacPorts吗?链接两个目录?将MacPorts安装移至/Library/Frameworks/...?

What's my best action now? Delete /Library/Frameworks/.../python2.7 and move easy_install and pip to the MacPorts one at /opt/local/...? Link the two directories? Move the MacPorts installation to /Library/Frameworks/...?

如何合并这些Python?我尝试过将两个站点包位置都放在路径中,但是只有某些包仅可用于一个Python,而另一包则不可用,反之亦然,我需要将它们全部一次提供.

How can I consolidate these Pythons? I have tried putting both site-packages locations in my path, but only certain packages are available only for one Python and not the other and others vice versa, and I need them all available at once.

推荐答案

似乎您可以控制自己构建的内容.这就是我用pip整合macports的方式:

It seems that you have control over the stuff you're building yourself. This is how I consolidate macports with pip:

我喜欢将 Macports 用于所有内容,因此,只需确保将pipeasy_install内置到macports的python安装中(/opt/local/...中的一个).

I like using Macports for all my stuff, so I just make sure that pip and easy_install build into macports' installation of python (the one in /opt/local/...).

您可以使用以下方法确定pip和easy_install会将其安装在何处:

You can tell where pip and easy_install will install things by using:

readlink `which pip`

(那些是反引号)

如果您希望将pip安装到macports目录中,请使用macports安装pip:

If you want pip to install to the macports direcectories, use macports to install pip:

sudo port install py-pip

然后,确保which pip指向类似以下内容的东西:

Then, be sure that which pip points to something like:

askewchan@rock:~$ which pip
/opt/local/bin/pip
askewchan@rock:~$ readlink `which pip`
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pip-2.7

在下面的注释中(感谢@Jonathan和@Ned),您可以对easy_install执行相同的操作,但其端口称为py-distribute:

From the comments below (thanks @Jonathan and @Ned) you can do the same with easy_install but its port is called py-distribute:

sudo port install py-distribute

但是据我所知,您永远不需要使用easy_install,因为可以easy_install ed可以更好地pip .

But as far as I know, you never need to use easy_install because anything that can be easy_installed can be piped better.

请注意端口说明:

askewchan@rock:Tracking {master *}$ port search *easy*install*
py-pip @1.2.1 (python, www)
    An easy_install replacement

askewchan@rock:Tracking {master *}$ port search py*distribute
py-distribute @0.6.35 (python, devel)
    Replacement for setuptools

这篇关于在OSX Mountain Lion上实际安装了太多的Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 19:27