django-crontab中print命令的语法错误无效

时间:2015-10-22 20:17:11

标签: python django

我在django-crontab中的有效Python 3打印命令上收到无效的语法错误:

python3 manage.py crontab add

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/local/lib/python3.2/dist-packages/django/core/management/__init__.py", line 40, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python3.2/importlib/__init__.py", line 124, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 821, in _gcd_import
    loader.load_module(name)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 436, in load_module
    return self._load_module(fullname)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 141, in decorated
    return fxn(self, module, *args, **kwargs)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 342, in _load_module
    exec(code_object, module.__dict__)
  File "/usr/local/lib/python3.2/dist-packages/django_crontab/management/commands/crontab.py", line 4, in <module>
    from django_crontab.crontab import Crontab
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 436, in load_module
    return self._load_module(fullname)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 141, in decorated
    return fxn(self, module, *args, **kwargs)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 330, in _load_module
    code_object = self.get_code(name)
  File "/usr/lib/python3.2/importlib/_bootstrap.py", line 413, in get_code
    dont_inherit=True)
  File "/usr/local/lib/python3.2/dist-packages/django_crontab/crontab.py", line 97
    print(u'Currently active jobs in crontab:')
                                             ^
SyntaxError: invalid syntax

我添加了&#39; django_crontab&#39;到设置中的INSTALLED_APPS,我已使用:

指定了作业
CRONJOBS = [
    ('0 0 * * *', 'app.cron.update_entries'),
    ('0 * * * *', 'app.cron.delete_queries')
]

人们怎么了,好像它是以Python 2代码运行的?

1 个答案:

答案 0 :(得分:1)

print不是无效的,而是u前缀。 Python 3.2不支持这一点。你应该升级到至少3.3。