OSX安装Python分发

OSX安装Python分发,python,python-2.7,installation,osx-mavericks,distribute,Python,Python 2.7,Installation,Osx Mavericks,Distribute,我正试图用python 2.7在mac上安装distribute,以访问easy\u install命令。 我下载了最新版本: curl-Ohttp://python-distribute.org/distribute_setup.py 并尝试运行安装脚本: sudo python distribute\u setup.py 但我收到了这个错误: $ sudo python distribute_setup.py Downloading http://pypi.python.org/packag

我正试图用python 2.7在mac上安装distribute,以访问
easy\u install
命令。 我下载了最新版本:
curl-Ohttp://python-distribute.org/distribute_setup.py

并尝试运行安装脚本:
sudo python distribute\u setup.py

但我收到了这个错误:

$ sudo python distribute_setup.py
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.49.tar.gz
Extracting in /tmp/tmpth5J26
Now working in /tmp/tmpth5J26/distribute-0.6.49
Installing Distribute
Before install bootstrap.
Scanning installed packages
No setuptools distribution found
running install
Checking .pth file support in /Users/[my username]/Library/Python/2.6/site-packages/
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -E -c pass
TEST FAILED: /Users/[my username]/Library/Python/2.6/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Users/[my username]/Library/Python/2.6/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  http://packages.python.org/distribute/easy_install.html#custom-installation-locations

Please make the appropriate changes for your system and try again.
Something went wrong during the installation.
See the error message above.
我验证了未设置
$PYTHONPATH
变量:

$ echo $PYTHONPATH

$
我不明白。我关心的另一件事是,我想用python 2.7安装它,但
/Users/[my username]/Library/python/2.7/site packages/
目录甚至不存在。如果可能的话,我宁愿不使用macports或家用brew,因为我发现它们很凌乱。 以下是一些版本信息:

还有关于我的python安装的更多信息:

$ python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py
import site # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py
import os # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc
import errno # builtin
import posix # builtin
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py
import posixpath # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.py
import stat # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py
import genericpath # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.py
import warnings # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/linecache.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/linecache.py
import linecache # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/linecache.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/types.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/types.py
import types # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/types.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py
import UserDict # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py
import _abcoll # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/abc.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/abc.py
import abc # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/abc.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_weakrefset.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_weakrefset.py
import _weakrefset # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_weakrefset.pyc
import _weakref # builtin
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.py
import copy_reg # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy_reg.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/traceback.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/traceback.py
import traceback # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/traceback.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py
import sysconfig # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py
import re # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py
import sre_compile # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.pyc
import _sre # builtin
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_parse.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_parse.py
import sre_parse # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_parse.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_constants.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_constants.py
import sre_constants # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_constants.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py
import _sysconfigdata # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.py
import _osx_support # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.pyc
import encodings # directory /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/__init__.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/__init__.py
import encodings # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/__init__.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py
import codecs # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.pyc
import _codecs # builtin
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/aliases.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/aliases.py
import encodings.aliases # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/aliases.pyc
# /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.pyc matches /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py
import encodings.utf_8 # precompiled from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.pyc
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so

您的问题是它找不到python库目录的路径

尝试手动将
$PYTHONPATH
环境变量(作为根)设置为
sys.path
变量。使用此命令:

export PYTHONPATH=`python -c 'import sys;print ":".join(sys.path)'`
然后再次运行安装程序脚本。请记住,如果以root身份运行安装程序脚本,则必须将环境变量设置为root


希望这有帮助

您是否考虑过使用
pip
而不是
easy\u install
easy\u install
已被弃用…@MattDMo我尝试获取
easy\u install
的原因是我正在尝试安装另一个程序,其setup.py需要
easy\u install
。distribute中不包括
pip
吗?@MattDMo另外,根据自制软件,我需要
easy\u安装
pip<代码>$brew安装pip错误:没有可用的pip公式:Homebrew通过“brew安装python”提供pip。不过,你的Mac电脑上会安装两个Python,所以你也可以:sudo easy_install pip,这只是为自制软件设计的。Pip可以不使用
分发
。但是,它确实需要
setuptools
,安装指南会告诉您如何事先安装。@MattDMo不幸的是,在运行setuptools的ez_setup.py文件后,我得到了一个与上面问题中描述的错误几乎相同的错误
export PYTHONPATH=`python -c 'import sys;print ":".join(sys.path)'`