Skip to content Skip to sidebar Skip to footer

Django : Execute Command Collectstatic Raise Unicodedecodeerror

Why raise UnicodeDecodeError? I try to deploy my django app using apache to copy static files, typing $python manage.py collectstatic and I got error message like below. You have

Solution 1:

Looks like one or more paths to your static files that are going to be copied contains non ASCII characters.

It has nothing to do with the path to the desctination directory.

One way to find out would be to put

try:
    print path
except:
    passtry:
    print entry
except:
    pass

just before line 236 in /usr/local/lib/python2.7/dist-packages/django/core/files/storage.py for a moment and then run manage.py again.

Then you should see where the problem occurs (you won't see the very culprit but the file just before it and propably directory of the problematic file).

Or, alternatively, you can use pdb:

python -m pdb manage.py collectstatic

and check which file is causing the problem in debugger.

Solution 2:

I had the same error when I used django-pipeline inside docker container. It turned out that for some reason the system used POSIX locale. I used the solution proposed here and exported locale setting in system shell:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

You can check that afterwards your locale should be like:

vagrant@vagrant-ubuntu-trusty-64:/project$ locale
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

It worked well. Also, notice I did that both in docker and outside machine.

Post a Comment for "Django : Execute Command Collectstatic Raise Unicodedecodeerror"