OSX安装Python Distribute

时间:2014-01-04 21:04:15

标签: python python-2.7 installation osx-mavericks distribute

我正在尝试使用python 2.7 在我的mac上安装分发以访问easy_install命令。 我下载了最新版本: curl -O http://python-distribute.org/distribute_setup.py

并尝试运行安装脚本: sudo python distribute_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或home-brew,因为我发现它们很混乱。 这是一些版本信息: About This Mac Screenshot

$ python -V
Python 2.7.6

关于我的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

1 个答案:

答案 0 :(得分:1)

您的问题是它无法找到python库目录的路径。

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

export PYTHONPATH=`python -c 'import sys;print ":".join(sys.path)'`

然后再次运行安装程序脚本。请记住,如果以root身份运行安装程序脚本,则必须将环境变量设置为root。

希望这有帮助!