mu-editor / mu

A small, simple editor for beginner Python programmers. Written in Python and Qt5.
http://codewith.mu
GNU General Public License v3.0
1.41k stars 435 forks source link

mu 1.0.2 Can't open directly from launchpad on macOS #743

Closed JohnGuan closed 5 years ago

JohnGuan commented 5 years ago

Can't open directly from Launchpad on macOS, but can start in Terminal. macOS version: 10.14.2 (18C54)

2019-01-18 11:18:28,589 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:18:49,586 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:20:42,166 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:21:20,405 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:21:51,573 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:22:03,638 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:22:21,222 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:25:53,070 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:25:59,386 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:26:35,579 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:34:54,291 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 11:53:13,096 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 12:09:00,113 - root:112(run) INFO: 

-----------------

Starting Mu 1.0.2
2019-01-18 12:09:00,114 - root:113(run) INFO: uname_result(system='Darwin', node='guanninuandeMBP.lan', release='18.2.0', version='Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64', machine='x86_64', processor='i386')
2019-01-18 12:09:00,114 - root:114(run) INFO: Python path: ['/Applications/mu-editor.app/Contents/MacOS', '/Applications/mu-editor.app/Contents/Resources/python/lib/python36.zip', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/lib-dynload', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/site-packages', '/Applications/mu-editor.app/Contents/Resources/app', '/Applications/mu-editor.app/Contents/Resources/app_packages', '/Applications/mu-editor.app/Contents/Resources/app_packages/IPython/extensions']
2019-01-18 12:09:00,115 - root:115(run) INFO: Language code: zh_CN
2019-01-18 12:09:00,454 - mu.logic:543(__init__) INFO: Setting up editor.
2019-01-18 12:09:00,455 - mu.logic:562(__init__) INFO: Settings path: /Users/johnguan/Library/Application Support/mu/settings.json
2019-01-18 12:09:00,456 - mu.logic:563(__init__) INFO: Session path: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 12:09:00,456 - mu.logic:564(__init__) INFO: Log directory: /Users/johnguan/Library/Logs/mu
2019-01-18 12:09:00,456 - mu.logic:565(__init__) INFO: Data directory: /Users/johnguan/Library/Application Support/mu
2019-01-18 12:09:00,468 - mu.logic:578(setup) INFO: Available modes: python, adafruit, microbit, debugger, pygamezero
2019-01-18 12:09:00,661 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 12:09:00,697 - mu.logic:627(restore_session) INFO: Restoring session from: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 12:09:00,698 - mu.logic:628(restore_session) DEBUG: {'theme': 'day', 'mode': 'microbit', 'paths': [], 'envars': [], 'minify': False, 'microbit_runtime': ''}
2019-01-18 12:09:00,698 - mu.logic:649(restore_session) INFO: Loaded files.
2019-01-18 12:09:00,698 - mu.logic:653(restore_session) INFO: User defined environment variables: []
2019-01-18 12:09:00,698 - mu.logic:657(restore_session) INFO: Minify scripts on micro:bit? False
2019-01-18 12:09:00,802 - mu.logic:680(restore_session) INFO: Starting with blank file.
2019-01-18 12:09:00,814 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 12:09:08,256 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 12:09:19,793 - mu.logic:1053(quit) DEBUG: Session: {'theme': 'day', 'mode': 'microbit', 'paths': [], 'envars': [], 'minify': False, 'microbit_runtime': '', 'zoom_level': 2}
2019-01-18 12:09:19,793 - mu.logic:1054(quit) DEBUG: Saving session to: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 12:09:19,793 - mu.logic:1068(quit) INFO: Quitting.

2019-01-18 12:09:23,477 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 12:09:26,732 - root:112(run) INFO: 

-----------------

Starting Mu 1.0.2
2019-01-18 12:09:26,732 - root:113(run) INFO: uname_result(system='Darwin', node='guanninuandeMBP.lan', release='18.2.0', version='Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64', machine='x86_64', processor='i386')
2019-01-18 12:09:26,732 - root:114(run) INFO: Python path: ['/Applications/mu-editor.app/Contents/MacOS', '/Applications/mu-editor.app/Contents/Resources/python/lib/python36.zip', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/lib-dynload', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/site-packages', '/Applications/mu-editor.app/Contents/Resources/app', '/Applications/mu-editor.app/Contents/Resources/app_packages', '/Applications/mu-editor.app/Contents/Resources/app_packages/IPython/extensions']
2019-01-18 12:09:26,732 - root:115(run) INFO: Language code: zh_CN
2019-01-18 12:09:26,994 - mu.logic:543(__init__) INFO: Setting up editor.
2019-01-18 12:09:26,994 - mu.logic:562(__init__) INFO: Settings path: /Users/johnguan/Library/Application Support/mu/settings.json
2019-01-18 12:09:26,995 - mu.logic:563(__init__) INFO: Session path: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 12:09:26,995 - mu.logic:564(__init__) INFO: Log directory: /Users/johnguan/Library/Logs/mu
2019-01-18 12:09:26,995 - mu.logic:565(__init__) INFO: Data directory: /Users/johnguan/Library/Application Support/mu
2019-01-18 12:09:27,007 - mu.logic:578(setup) INFO: Available modes: python, adafruit, microbit, debugger, pygamezero
2019-01-18 12:09:27,143 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 12:09:27,171 - mu.logic:627(restore_session) INFO: Restoring session from: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 12:09:27,171 - mu.logic:628(restore_session) DEBUG: {'theme': 'day', 'mode': 'microbit', 'paths': [], 'envars': [], 'minify': False, 'microbit_runtime': '', 'zoom_level': 2}
2019-01-18 12:09:27,171 - mu.logic:649(restore_session) INFO: Loaded files.
2019-01-18 12:09:27,171 - mu.logic:653(restore_session) INFO: User defined environment variables: []
2019-01-18 12:09:27,171 - mu.logic:657(restore_session) INFO: Minify scripts on micro:bit? False
2019-01-18 12:09:27,263 - mu.logic:680(restore_session) INFO: Starting with blank file.
2019-01-18 12:09:27,273 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 12:09:42,310 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 12:10:45,497 - mu.logic:695(toggle_theme) INFO: Toggle theme to: night
2019-01-18 12:10:46,637 - mu.logic:695(toggle_theme) INFO: Toggle theme to: contrast
2019-01-18 12:10:47,673 - mu.logic:695(toggle_theme) INFO: Toggle theme to: day
2019-01-18 12:10:48,152 - mu.logic:695(toggle_theme) INFO: Toggle theme to: night
2019-01-18 12:10:49,423 - mu.logic:695(toggle_theme) INFO: Toggle theme to: contrast
2019-01-18 12:10:50,022 - mu.logic:695(toggle_theme) INFO: Toggle theme to: day
2019-01-18 12:10:52,131 - mu.logic:695(toggle_theme) INFO: Toggle theme to: night
2019-01-18 12:10:53,826 - mu.logic:695(toggle_theme) INFO: Toggle theme to: contrast
2019-01-18 12:10:57,099 - mu.logic:695(toggle_theme) INFO: Toggle theme to: day
2019-01-18 12:11:01,265 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 12:12:13,025 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 12:12:16,096 - mu.logic:1112(select_mode) INFO: New mode selected: python
2019-01-18 12:12:16,113 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 12:12:18,855 - mu.modes.python3:265(toggle_plotter) INFO: Toggle plotter on.
2019-01-18 12:12:18,889 - mu.modes.python3:276(add_plotter) INFO: Started plotter
2019-01-18 12:12:19,564 - mu.modes.python3:268(toggle_plotter) INFO: Toggle plotter off.
2019-01-18 12:12:19,564 - mu.modes.base:162(remove_plotter) DEBUG: Creating directory: /Users/johnguan/mu_code/data_capture
2019-01-18 12:12:19,567 - mu.modes.base:172(remove_plotter) INFO: Removing plotter
2019-01-18 12:12:20,632 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 12:12:25,274 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 12:12:28,028 - mu.logic:1112(select_mode) INFO: New mode selected: microbit
2019-01-18 12:12:28,040 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 12:12:29,144 - mu.modes.base:227(find_device) INFO: Found device on port: cu.usbmodem14102
2019-01-18 12:12:29,144 - mu.modes.base:228(find_device) INFO: Serial number: 9901000050294e4500422017000000330000000097969901
2019-01-18 12:12:29,163 - mu.modes.microbit:597(toggle_files) INFO: Toggle filesystem on.
2019-01-18 12:12:30,322 - mu.modes.microbit:122(ls) ERROR: Could not enter raw REPL.
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/modes/microbit.py", line 119, in ls
    result = tuple(microfs.ls())
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 181, in ls
    ], serial)
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 132, in execute
    raw_on(serial)
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 82, in raw_on
    raise IOError('Could not enter raw REPL.')
OSError: Could not enter raw REPL.
2019-01-18 12:12:30,345 - mu.interface.main:723(show_message) DEBUG: 获取 micro:bit 上的文件列表时出现问题。 请查看Mu的日志以获取技术信息。 或者尝试重新插拔 micro:bit 和重启 Mu 。
2019-01-18 12:12:30,345 - mu.interface.main:724(show_message) DEBUG: None
2019-01-18 12:12:38,768 - mu.modes.microbit:601(toggle_files) INFO: Toggle filesystem off.
2019-01-18 12:12:41,227 - mu.modes.base:227(find_device) INFO: Found device on port: cu.usbmodem14102
2019-01-18 12:12:41,227 - mu.modes.base:228(find_device) INFO: Serial number: 9901000050294e4500422017000000330000000097969901
2019-01-18 12:12:41,238 - mu.modes.microbit:597(toggle_files) INFO: Toggle filesystem on.
2019-01-18 12:12:42,389 - mu.modes.microbit:122(ls) ERROR: Could not enter raw REPL.
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/modes/microbit.py", line 119, in ls
    result = tuple(microfs.ls())
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 181, in ls
    ], serial)
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 132, in execute
    raw_on(serial)
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 82, in raw_on
    raise IOError('Could not enter raw REPL.')
OSError: Could not enter raw REPL.
2019-01-18 12:12:42,390 - mu.interface.main:723(show_message) DEBUG: 获取 micro:bit 上的文件列表时出现问题。 请查看Mu的日志以获取技术信息。 或者尝试重新插拔 micro:bit 和重启 Mu 。
2019-01-18 12:12:42,390 - mu.interface.main:724(show_message) DEBUG: None
2019-01-18 12:12:44,746 - mu.modes.microbit:601(toggle_files) INFO: Toggle filesystem off.
2019-01-18 13:43:14,452 - mu.logic:1077(show_admin) INFO: Showing logs from /Users/johnguan/Library/Logs/mu/mu.log
2019-01-18 14:15:29,643 - mu.logic:1107(select_mode) INFO: Showing available modes: ['python', 'adafruit', 'microbit', 'debugger', 'pygamezero']
2019-01-18 14:15:34,780 - mu.interface.main:751(show_confirmation) DEBUG: 你有还没有保存的代码,如果现在退出程序的话将不会保存。
2019-01-18 14:15:34,781 - mu.interface.main:752(show_confirmation) DEBUG: None
2019-01-18 14:15:36,633 - mu.logic:1053(quit) DEBUG: Session: {'theme': 'day', 'mode': 'microbit', 'paths': [], 'envars': [], 'minify': False, 'microbit_runtime': '', 'zoom_level': 2}
2019-01-18 14:15:36,633 - mu.logic:1054(quit) DEBUG: Saving session to: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 14:15:36,635 - mu.logic:1068(quit) INFO: Quitting.

2019-01-18 14:15:40,703 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 14:15:43,384 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 14:15:46,661 - root:95(excepthook) ERROR: Unrecoverable error
Traceback (most recent call last):
  File "/Applications/mu-editor.app/Contents/MacOS/mu-editor", line 20, in <module>
    load_entry_point('mu-editor==1.0.2', 'console_scripts', 'mu-editor')()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 111, in run
    setup_logging()
  File "/Applications/mu-editor.app/Contents/Resources/app/mu/app.py", line 66, in setup_logging
    print(_('Logging to {}').format(LOG_FILE))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
2019-01-18 14:15:50,222 - root:112(run) INFO: 

-----------------

Starting Mu 1.0.2
2019-01-18 14:15:50,222 - root:113(run) INFO: uname_result(system='Darwin', node='guanninuandeMBP.lan', release='18.2.0', version='Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64', machine='x86_64', processor='i386')
2019-01-18 14:15:50,222 - root:114(run) INFO: Python path: ['/Applications/mu-editor.app/Contents/MacOS', '/Applications/mu-editor.app/Contents/Resources/python/lib/python36.zip', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/lib-dynload', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/site-packages', '/Applications/mu-editor.app/Contents/Resources/app', '/Applications/mu-editor.app/Contents/Resources/app_packages', '/Applications/mu-editor.app/Contents/Resources/app_packages/IPython/extensions']
2019-01-18 14:15:50,222 - root:115(run) INFO: Language code: zh_CN
2019-01-18 14:15:50,515 - mu.logic:543(__init__) INFO: Setting up editor.
2019-01-18 14:15:50,516 - mu.logic:562(__init__) INFO: Settings path: /Users/johnguan/Library/Application Support/mu/settings.json
2019-01-18 14:15:50,516 - mu.logic:563(__init__) INFO: Session path: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 14:15:50,516 - mu.logic:564(__init__) INFO: Log directory: /Users/johnguan/Library/Logs/mu
2019-01-18 14:15:50,516 - mu.logic:565(__init__) INFO: Data directory: /Users/johnguan/Library/Application Support/mu
2019-01-18 14:15:50,529 - mu.logic:578(setup) INFO: Available modes: python, adafruit, microbit, debugger, pygamezero
2019-01-18 14:15:50,680 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 14:15:50,707 - mu.logic:627(restore_session) INFO: Restoring session from: /Users/johnguan/Library/Application Support/mu/session.json
2019-01-18 14:15:50,707 - mu.logic:628(restore_session) DEBUG: {'theme': 'day', 'mode': 'microbit', 'paths': [], 'envars': [], 'minify': False, 'microbit_runtime': '', 'zoom_level': 2}
2019-01-18 14:15:50,707 - mu.logic:649(restore_session) INFO: Loaded files.
2019-01-18 14:15:50,707 - mu.logic:653(restore_session) INFO: User defined environment variables: []
2019-01-18 14:15:50,707 - mu.logic:657(restore_session) INFO: Minify scripts on micro:bit? False
2019-01-18 14:15:50,803 - mu.logic:680(restore_session) INFO: Starting with blank file.
2019-01-18 14:15:50,815 - mu.logic:1150(change_mode) INFO: Workspace directory: /Users/johnguan/mu_code
2019-01-18 14:15:54,536 - mu.logic:1077(show_admin) INFO: Showing logs from /Users/johnguan/Library/Logs/mu/mu.log
2019-01-18 16:12:11,529 - mu.logic:1077(show_admin) INFO: Showing logs from /Users/johnguan/Library/Logs/mu/mu.log
2019-01-18 16:17:49,659 - mu.logic:1077(show_admin) INFO: Showing logs from /Users/johnguan/Library/Logs/mu/mu.log
ntoll commented 5 years ago

@tmontes this didn't used to happen. Could it be something to do with the changes you made to OSX locale detection? (This is just a hunch based on what has/hasn't changed since the last release.)

ntoll commented 5 years ago

OK... here's what I've learned.

Previously, because of the odd way OSX does locale, it was falling back to "English" as the default language, so the print statement on line 66 was getting the string "Logging to ...". Now that Mu correctly detects OSX locale settings (thanks @tmontes), the print statement is getting the text translated into Chinese (presumably your locale): "记录日志到 /Users/johnguan/Library/Logs/mu/mu.log"

At this point, Python complains about encoding problems and breaks.

tmontes commented 5 years ago

@ntoll, thanks for pinging me. :)

I'll definitely try to have a look at this sometime later today. A few notes off the top of my head:

Pseudo-reproduction example:

$ python3.6
Python 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.encoding
'UTF-8'
>>> s = '记录日志到'
>>> print(s)             # works, `s` successfully encoded to UTF-8
记录日志到
>>> s.encode('UTF-8')    # confirmation
b'\xe8\xae\xb0\xe5\xbd\x95\xe6\x97\xa5\xe5\xbf\x97\xe5\x88\xb0'
>>> s.encode('ASCII')    # pseudo-reproduction
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
>>>

I get the same exact behaviour on CPython 3.7 here.

Suspicion: the CPython startup process is setting sys.stdout.encoding to something that can't encode the localised message. Needs further investigation which I'll try to do later today.

tmontes commented 5 years ago

Progress - Confirmed suspicion above.

What I did:

Possible quick fixes:

"Real" fixes:

Plan on doing further investigation:

tmontes commented 5 years ago

@JohnGuan,

Do you think you could "hack" your mu installation -- with our guidance -- to see if we can make it work for you, when launched from the launchpad? This would be helpful in confirming the root cause of the issue on your system.

The idea would be:

If this is something you feel you could try then great:

Otherwise, if this feels to complex don't worry. I'm sure we'll be able to make it work otherwise.

ntoll commented 5 years ago

@tmontes thank you! What you've just written on this issue is exactly my reading of the situation. I have already walked @JohnGuan through similar steps (although I omitted to ask for sys.stdout.encoding).

I believe the simplest solution is simply to remove the print statement. We only use print once and it's only there because I didn't remove it when I added the "log" pane to the UI (it helped sys admins at school find out what Mu was complaining about).

Ergo, I'll remove print and update the installers with the change.

tmontes commented 5 years ago

(now away from laoptop/code but...)

While you are at it, it may make sense to remove (or wrap in a try/except UnicodeEncodingError) any other print calls the code may have lying around... I have the feeling I saw at least one more. :)

ntoll commented 5 years ago

Folks, I've just updated the Mac package so it doesn't contain the problematic print statement. Ergo, I'll close this issue. Thanks for the report and efforts in diagnosing things.

ntoll commented 5 years ago

@tmontes I had a look at the use of print in the code base. We don't have any further uses which use gettext (i.e. all other print statements are in "contrib" modules which are outputting English ASCII informational messages.

tmontes commented 5 years ago

@ntoll that's good... :) But won't this one here, app.py:debug() be potentially problematic?

ntoll commented 5 years ago

How did I miss that? Doh. You have very sharp eyes.

Yes... I agree. That could be problematic. I'll re-open.

tmontes commented 5 years ago

...I'm not sure under which circumstances the print in app.py:debug() would run -- IOW: how would it be missing the module to be debugged? Regardless of that, even if the argument isn't present, how would that print output reach a potential user? Is it captured somehow and displayed in a graphical pane? Or is the debugger supposed to be runnable from a command line interface as well, for more advanced users?

ntoll commented 5 years ago

The way the debugger works is described here: https://mu.readthedocs.io/en/latest/debugger.html#graphical-debugger

Basically, this entry point is used by the DebugRunner side of things to launch the code to be debugged. The output from this process is displayed in Mu's run pane - used to show and capture stdin/stdout.

Does this make sense?

I agree it may need a try/except around it though, for the same reason we removed the print statement.

Having said that, the ONLY way this block of code could be reached is if the user launched the DebugRunner "manually" from the command line WITHOUT specifying the python file to be debugged. Mu always launches the DebugRunner with a filename (it checks/complains if there's no filename), so "normal" users will never encounter this code branch. The only person on the planet who is ever likely to launch the DebugRunner "manually" is me, for development purposes, and I don't speak Chinese. ;-)

If you're happy that the chances of a Chinese speaking developer manually running the DebugRunner are sufficiently small (i.e. I think the chances are basically zero), then I'm happy to close this issue again. However, I can't help but smile to myself and think this sort of attitude is bound to come back and haunt me in the future. ;-)

tmontes commented 5 years ago

The way the debugger works is described here: https://mu.readthedocs.io/en/latest/debugger.html#graphical-debugger

Basically, this entry point is used by the DebugRunner side of things to launch the code to be debugged. The output from this process is displayed in Mu's run pane - used to show and capture stdin/stdout.

...thanks for the pointer and mini-overview. :)

I agree it may need a try/except around it though, for the same reason we removed the print statement.

Having said that, the ONLY way this block of code could be reached is if the user launched the DebugRunner "manually" from the command line WITHOUT specifying the python file to be debugged. Mu always launches the DebugRunner with a filename (it checks/complains if there's no filename), so "normal" users will never encounter this code branch. The only person on the planet who is ever likely to launch the DebugRunner "manually" is me, for development purposes, and I don't speak Chinese. ;-)

If you're happy that the chances of a Chinese speaking developer manually running the DebugRunner are sufficiently small (i.e. I think the chances are basically zero), then I'm happy to close this issue again. However, I can't help but smile to myself and think this sort of attitude is bound to come back and haunt me in the future. ;-)

My take:

What do you say?

PS: It took me more time to write these words that it would have taken me/you implementing the change. :)

tjguk commented 5 years ago

FWIW I agree with @tmontes in principle.

But also I'd add what is doubtless obvious to both of you: that having the discussion and thought process "out loud" as it were is so helpful later when you can't quite remember what process you went through to get to that point. (Even if you dutifully put good comments in place).

That's where I'm haltingly trying to go with my design notes idea:

https://github.com/mu-editor/mu/tree/master/docs/design

ntoll commented 5 years ago

+1 to the assessment, discussion and suggested solution. Also +1 to public discussion about such things. Thank you @tmontes and @tjguk. I'll fix right now.

tmontes commented 5 years ago

Thanks @ntoll + @tjguk for your inputs and guidance. :)