I'm trying to use aptana studio 3 for a django project, but got a unicodedecodeerror no matter what i did.
After a lot of unsuccessful google searches, tried a barebones django project. Not a line of code from me, just the start code from aptana.
I expected the usual blank page from django (project working, nothing done yet), but STILL got the encode error. I didn't write a single line of code, so there's no template with latin characters or any other encoding/decoding.
Tried:
Windows->Preferences->General->Workspace->Text file encoding to UTF-8
Right click on project ->Resource->Text file encoding to UTF-8
# - - coding: utf-8 - - on first line of every file
Nothing Worked.
I'm kind of stuck here. Can anyone help?
Win7 64bit
Error message from console:
Validating models...
0 errors found
April 02, 2014 - 17:55:34
Django version 1.6, using settings 'hello.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Traceback (most recent call last):
File "C:\Users\bruna\Documents\Aptana Studio 3 Workspace\hello\src\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 285, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 76, in handle
self.run(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 87, in run
self.inner_run(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 132, in inner_run
self.stderr.write("Error: %s" % error_text)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 65, in write
if ending and not msg.endswith(ending):
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 87: invalid continuation byte
Judging by the stacktrace (the actual place where you should look for the root cause), there's something about msg
(most likely, since ending
is hardly 87 chars long) in if ending and not msg.endswith(ending):
that isn't valid utf-8. This is probably an encoding issue in a settings file or input parameter.
I suggest to:
msg
or add a debug printing of repr(msg)
before the offending lineYou try:
manage.py dbshell
ALTER TABLE database.table MODIFY COLUMN col VARCHAR(255) CHARACTER SET utf8 COLLATE
utf8_general_ci NOT NULL;
Change database.table and col. Enjoy !
One reason is ,you used sed with grep in the past time like this:
sed -i "s#views_gaoji#fenye#g"
grep -rl views_gaoji ./`
The above command will modify .pyc file without notification for you.
Then when you start your Django, Django will start from .pyc,NOT from your engineering file.
Then you will get error without knowing where the error is OR you will get error in your manage.py
file but you never modify it,
so why did it say,your manage.py has error?
That's because you *.pyc file are changed by sed
command
Solution:
find . -name "*.pyc" | xargs rm -f
and then type:
python manage.py runserver port
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.