45

第一次尝试使用 Sphinx,安装干净的 Sphinx 1.1.3,但 shinx-quickstart 失败。是否应该安装任何依赖项?我试过了,pip --force-reinstall sphinx但结果是一样的。

  myhost:doc anton$ sphinx-quickstart 
  Traceback (most recent call last):
  File "/usr/local/bin/sphinx-quickstart", line 8, in <module>
    load_entry_point('Sphinx==1.1.3', 'console_scripts', 'sphinx-quickstart')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 318, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2221, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1954, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/Library/Python/2.7/site-packages/Sphinx-1.1.3-py2.7.egg/sphinx/quickstart.py", line 19, in <module>
    from sphinx.util.osutil import make_filename
  File "/Library/Python/2.7/site-packages/Sphinx-1.1.3-py2.7.egg/sphinx/util/__init__.py", line 25, in <module>
    from docutils.utils import relative_path
  File "/Library/Python/2.7/site-packages/docutils-0.9-py2.7.egg/docutils/utils/__init__.py", line 19, in <module>
    from docutils.io import FileOutput
  File "/Library/Python/2.7/site-packages/docutils-0.9-py2.7.egg/docutils/io.py", line 18, in <module>
    from docutils.error_reporting import locale_encoding, ErrorString, ErrorOutput
  File "/Library/Python/2.7/site-packages/docutils-0.9-py2.7.egg/docutils/error_reporting.py", line 47, in <module>
    locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 496, in getdefaultlocale
    return _parse_localename(localename)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 428, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename

  ValueError: unknown locale: UTF-8
4

1 回答 1

94

我在 Mac OS X Snow Leopard 中遇到了同样的问题。这似乎是 Terminal.app 的问题。

请将以下内容添加到您的 $HOME/.bash_profile

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

source $HOME/.bash_profile

并尝试。这将解决问题。

于 2012-06-07T05:24:19.013 回答