I am trying to run some cronjobs in django.
I have three of them, 2 of them are running flawlessly. but the third one is giving me the error:
../../monthly_abo_live.py", line 1
SyntaxError: encoding problem: with BOM
the first 2 lines of this file are:
1. # -*- coding: utf-8 -*-
2. from django.core.management.base import BaseCommand, CommandError
3. ...
the other 2 cronjobs are the same as this one. i am stuck - why only this one is complaining? It seems python doesnot support utf-8
? it cannot be, right?
According to this page:
http://legacy.python.org/dev/peps/pep-0263/
you have two options...
To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file, such as:
# coding=<encoding name>
or (using formats recognized by popular editors)
#!/usr/bin/python
# -*- coding: <encoding name> -*-
(Note: While the above is a direct quote, @tdelaney pointed out - and I agree - that instead of the fixed path #!/usr/bin/python
one should use #!/usr/bin/env python
.)
It looks like you're using part of the second option but did not include the required first line ( #!/usr/bin/python
). Try inserting that before your "coding" line and see what happens.