Python相对导入导致语法错误:无效语法

发布于 2024-09-26 18:46:53 字数 506 浏览 0 评论 0原文

我正在尝试将这个很棒的 python 模块 Python-Chrono 安装到我的 python 环境中,但它至少在 python 2.4.3 和 2.6.6 中失败,并显示以下错误消息:

Traceback (most recent call last): 
  File "setup.py", line 30, in ?
    import chrono
  File "/home/janne/python-chrono-0.3.0/chrono/__init__.py", line 22
    from . import calendar
         ^
SyntaxError: invalid syntax

安装程序正在使用相对导入机制,它应该工作得很好,但在我的环境中它会导致此错误。

有办法解决这个问题吗?您在项目中见过这种行为吗?

I'm trying to install this great python module Python-Chrono to my python environment, but it fails at least with python 2.4.3 and 2.6.6 with the following error message:

Traceback (most recent call last): 
  File "setup.py", line 30, in ?
    import chrono
  File "/home/janne/python-chrono-0.3.0/chrono/__init__.py", line 22
    from . import calendar
         ^
SyntaxError: invalid syntax

The setup is using relative import mechanism and it should work just fine, but in my environment it causes this error.

Is there a way to get this fixed? Have you seen this kind of behaviour in your projects?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若水般的淡然安静女子 2024-10-03 18:46:53

Python 2.4 不支持该语法 - 它是在 Python 2.5 中引入的。

(您是否 100% 确定 2.6 中出现该消息失败?)

Python 2.4 doesn't support that syntax - it was introduced in Python 2.5.

(Are you 100% sure that it's failing with that message in 2.6?)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文