question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)

See original GitHub issue

Make sure these boxes are checked before submitting your issue - thank you!

[-] I have checked the superset logs for python stacktraces and included it here as text if any [-] I have reproduced the issue with at least the latest released version of superset [-] I have checked the issue tracker for the same issue and I haven’t found one similar

Superset version

0.18.2

Expected results

Graphic a column diagram product sales group by date.

Actual results

Throws an exception: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128) Detail Stack Info:

2017-05-17 17:27:56,137:INFO:root:SELECT `TIMESTAMP` AS `TIMESTAMP`, product AS product, COUNT(*) AS count 
FROM ja_act_lotterylog 
WHERE `TIMESTAMP` >= STR_TO_DATE('2016-11-20 17:27:56', '%%Y-%%m-%%d %%H:%%i:%%s') AND `TIMESTAMP` <= STR_TO_DATE('2016-11-30 17:27:56', '%%Y-%%m-%%d %%H:%%i:%%s') GROUP BY `TIMESTAMP`, product ORDER BY count DESC 
 LIMIT 50000
2017-05-17 17:28:05,548:ERROR:root:'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/superset/viz.py", line 237, in get_payload
    data = self.get_data(df)
  File "/usr/lib/python2.7/site-packages/superset/viz.py", line 1113, in get_data
    x = str(x)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
2017-05-17 17:28:05,551:INFO:root:Caching for the next 600000 seconds

Steps to reproduce

Add a MySQL datasource and table, then click Sources --> Tables --> Query, after that show result like below: snapshot2017-05-17-5.33.17.png

MySQL table data: snapshot2017-05-17-5.33.38.png

Remember that some meta data use in Chinese.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mistercrunchcommented, May 17, 2017

Also if you’re not using py3 it may help

0reactions
elkan1788commented, Aug 18, 2017

@RichardKyire I don’t known the deep reason. May you can check the DB environment suggest to use the “UTF-8” charset.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeEncodeError: 'ascii' codec can't encode character ...
The issue is that when you call str(), python uses the default character encoding to try and encode the bytes you gave it,...
Read more >
Fix Python UnicodeEncodeError: 'ascii' codec can't encode ...
UnicodeEncodeError : 'ascii' codec can't encode character u'\u03b1' in position 20: ordinal not in range(128). Additionally, when writing pandas DataFrames ...
Read more >
UnicodeEncodeError 'ascii' 'ordinal not in range(128)'
UnicodeEncodeError : 'ascii' codec can't encode character u'\xa3' in position 53331: ordinal not in range(128) Before the test I made above, ...
Read more >
'ascii' codec can't encode character '\xe9' in position 117: ...
UnicodeEncodeError : 'ascii' codec can't encode character '\xe9' in position 117: ordinal not in range(128) #10219. Closed. 1 task done.
Read more >
UnicodeEncodeError: 'ascii' codec can't encode character ...
This error occurs when we pass a Unicode string containing non-English characters (Unicode characters beyond 128) to something that expects an ASCII ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found