這是我的previous question的後續行動。如何配置我的Python 2.7以在我的OSX Mavericks系統上使用正確的Babel安裝?
我有一臺OSX Mavericks機器,我使用MacPorts安裝Python 2.7和Babel 1.3。 問題是,它似乎我至少有兩個版本的babel在該機器上,除了我使用MacPort安裝的,另一個沒有安裝CLDR語言環境數據文件,所以當我在我的應用程序中執行以下命令目錄:
pybabel extract -o ./locale/messages.pot ./
我收到此錯誤信息:
[...]
writing PO template file to ./locale/messages.pot
Traceback (most recent call last):
File "/usr/local/bin/pybabel", line 8, in <module>
load_entry_point('Babel==2.0-dev-20131218', 'console_scripts', 'pybabel')()
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/messages/frontend.py", line 1151, in main
return CommandLineInterface().run(sys.argv)
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/messages/frontend.py", line 665, in run
return getattr(self, cmdname)(args[1:])
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/messages/frontend.py", line 947, in extract
sort_by_file=options.sort_by_file)
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/messages/pofile.py", line 427, in write_po
messages = list(catalog)
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/messages/catalog.py", line 552, in __iter__
for name, value in self.mime_headers:
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/messages/catalog.py", line 337, in _get_mime_headers
locale='en')))
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/dates.py", line 609, in format_datetime
locale = Locale.parse(locale)
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/core.py", line 284, in parse
language = get_global('language_aliases').get(language, language)
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/core.py", line 53, in get_global
_raise_no_data_error()
File "/Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel/core.py", line 25, in _raise_no_data_error
raise RuntimeError('The babel data files are not available. '
RuntimeError: The babel data files are not available. This usually happens because you are using a source checkout from Babel and you did not build the data files. Just make sure to run "python setup.py import_cldr" before installing the library.
我發現安裝在我的機器上這些位置巴貝爾:
> cd /Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/
> ls
EGG-INFO babel
> cd babel
> ls
__init__.py core.py localedata.py numbers.py support.py
__init__.pyc core.pyc localedata.pyc numbers.pyc support.pyc
_compat.py dates.py localtime plural.py util.py
_compat.pyc dates.pyc messages plural.pyc util.pyc
> cd /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/babel
> ls
__init__.py core.py localedata numbers.py support.py
__init__.pyc core.pyc localedata.py numbers.pyc support.pyc
_compat.py dates.py localedata.pyc plural.py util.py
_compat.pyc dates.pyc localtime plural.pyc util.pyc
global.dat messages
這些都是在我的環境中定義的不同路徑:/本地
> alias pybabel='pybabel-2.7'
我怎樣才能讓巴貝爾看到在/ opt巴貝爾版本:
> echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/XXXXX/.rvm/bin
> echo $PYTHONPATH
> echo $DYLD_FALLBACK_LIBRARY_PATH
> echo $DYLD_LIBRARY_PATH
> echo $DYLD_FALLBACK_FRAMEWORK_PATH
> echo $DYLD_FRAMEWORK_PATH
>
pybabel是我使用下面的命令創建一個別名/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/babel?