Python相对导入导致语法错误:无效语法
我正在尝试将这个很棒的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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?)