【问题标题】:I cannot find setup.py in my OSX babel installation to import the cldr babel files, what am I doing wrong?我在我的 OSX babel 安装中找不到 setup.py 来导入 cldr babel 文件,我做错了什么?
【发布时间】:2020-10-14 06:22:40
【问题描述】:

我一直在尝试在我的 iMac 上使用 babel(OSX Mavericks,我使用 MacPorts 安装了 python 和 babel)但我收到了这个错误消息:

[...]
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.

我无法运行以下命令,因为我在 Mac 上的 .egg 存档中找不到 setup.py 文件

>python setup.py import_cldr

尝试在我下载的另一个版本的 babel 上运行 setup.py 导致了这个错误,但即使我能做到,我认为它也不能解决我的问题:

> python setup.py import_cldr
running import_cldr
Local copy '/Users/Ailete/Downloads/Babel-1.3/cldr/core-23.1.zip' not found
Downloading 'core-23.1.zip'
Traceback (most recent call last):
  File "scripts/download_import_cldr.py", line 104, in <module>
    main()
  File "scripts/download_import_cldr.py", line 82, in main
    urlretrieve(URL, zip_path, reporthook)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py",     line 94, in urlretrieve
    return _urlopener.retrieve(url, filename, reporthook, data)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 244, in retrieve
    tfp = open(filename, 'wb')
IOError: [Errno 2] No such file or directory: '/Users/Ailete/Downloads/Babel-1.3/cldr/core-23.1.zip'

知道如何安装 .egg 安装的 CLDR 文件吗?

这是我机器上babel包的内容:

> 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 /Library/Python/2.7/site-packages/Babel-2.0_dev_20131218-py2.7.egg/babel
> python setup.py import_cldr
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory
> python setup.py install
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory

【问题讨论】:

  • 这看起来像是 MacPorts 的 Babel 的打包问题。安装某些软件后,您不必自己获取丢失的数据文件。
  • 这就是你必须按照official documentation中所述的方式安装它
  • 是的,babel 文档仅描述了如何使用特定于 Python 的打包工具 (pip/setup.py) 进行安装,但如果您使用 MacPorts 等系统包管理器,则这些说明不适用.
  • 你说的有一部分是对的,事实上我没有在我的 HD 上看正确的地方,即使我的问题还没有解决,我也回答了我自己的问题,因为我必须弄清楚如何配置我的现在系统正常...

标签: python macos setup.py egg python-babel


【解决方案1】:

您必须进入它所在的目录,然后键入: “python setup.py install”(不带引号)。

~托马斯

【讨论】:

  • 没有setup.py怎么办?
【解决方案2】:

我想我正在查看系统安装的 babel 版本...

我发现 MacPorts 安装的东西在:

/opt/local/

我需要的 cldr 文件似乎位于:

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/babel/localedata/

我现在需要找到如何在 Mavericks 上正确设置路径......但我的问题似乎是系统没有使用正确版本的 Babel。

感谢您的回答,我会提出一个新问题来帮助我进行路径配置。

【讨论】:

猜你喜欢
  • 2018-05-27
  • 1970-01-01
  • 2017-06-22
  • 2021-09-10
  • 2017-09-29
  • 2018-12-04
  • 1970-01-01
  • 2020-02-13
  • 2020-05-23
相关资源
最近更新 更多