Error: 'ascii' codec can't decode byte 0xc3 in position 19: ordinal not in range(128)

After sync all sites is returning this:

Syncing help database...
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 94, in <module>
    main()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/site.py", line 221, in migrate
    compileall.compile_dir('../apps', quiet=1)
  File "/usr/lib/python2.7/compileall.py", line 57, in compile_dir
    quiet):
  File "/usr/lib/python2.7/compileall.py", line 57, in compile_dir
    quiet):
  File "/usr/lib/python2.7/compileall.py", line 41, in compile_dir
    names.sort()
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 19: ordinal not in range(128)
ubuntu@ip-172-31-19-194:~/frappe-bench$

I think this exact error has appeared before. I cant remember the details but please search in the forum’s and / or issues and you may find some helpful information

I found it some posts about this, but not helped me


Have you any custom apps?

Yes, I have

Does it involve language translation?

File “/usr/lib/python2.7/compileall.py”, line 41, in compile_dir
names.sort()
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position 19: ordinal not in range(128)

Can you give me an example about this?
Are you talking about __ on javascript?

My guess is the Python compiler does not ‘like’ your custom app code.

This page outlines how you can go to the custom app directory and run the compiler to identify the offending file 32.11. compileall — Byte-compile Python libraries — Python 2.7.18 documentation

This library don’t works for me, after run compile command on app/ folder, this does not return any error


ok these help explain your problem - a filename that Python runs afoul on


python - UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 23: ordinal not in range(128) - Stack Overflow
python - UnicodeDecodeError when performing os.walk - Stack Overflow

A console session like this example here can help you identify the problem filename -

frappe@erpnext:~/frappe-bench$ bench console
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
Type “copyright”, “credits” or “license” for more information.
IPython 5.1.0 – An enhanced Interactive Python.
? → Introduction and overview of IPython’s features.
%quickref → Quick reference.
help → Python’s own help system.
object? → Details about ‘object’, use ‘object??’ for extra details.
In [1]: os.listdir(‘/home/frappe/frappe-bench/apps/erpnext’)
Out[1]:
[u’.eslintrc’, u’MANIFEST.in’, u’erpnext.egg-info’, u’.gitignore’, u’.github’, u’setup.pyc’, u’sponsors.md’, u’travis’, u’.git’, u’erpnext’, u’requirements.txt’, u’.travis.yml’, u’__init__.py’, u’attributions.md’, u’test_sites’, u’__init__.pyc’, u’README.md’, u’CODE_OF_CONDUCT.md’, u’license.txt’, u’setup.py’]

I’ll uninstall and remove all custom apps on my dev machine and try run bench update again

So then you have identified and confirmed the problem source is indeed a filename?

So is this the problem character

u’ñ’
u’\xf1’
u’ñ’.encode(‘utf8’)
‘\xc3\xb1’
u’ñ’.encode(‘utf8’).encode(‘utf8’)
Traceback (most recent call last):
File “”, line 1, in
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position 0: ordinal not in range(128)

No, I try uninstalling custom apps but not works at all


I think the problem is the erpnext app, just there has this types of languages


Uninstalled all custom apps and the issue continues
 I think this is not a file name

“I think this is not a file name”

You have checked and can you confirm that? Your stack trace suggests otherwise

File “/usr/lib/python2.7/compileall.py”, line 41, in compile_dir
names.sort()

I’ve checked all of custom apps, folder by folder
There’s no way to see what’s the entire name with the compile?

“there’s no way to see what’s the entire name with the compile?”

Maybe try ‘ls -R apps/your_custom_app’ to view the filenames?

No, see the file name with problem hehehe

I’ll check again, thank’s in advance for now @clarkej :smiley: