New submission from Andrew Gallagher: This occurs when python is installed on a read-only mount AND all the .pyc files are out-of-date. Therefore, when python starts and attempts to write a new .pyc file, _write_atomic in "Lib/importlib/_bootstrap.py" throws an OSError with an errno of EROFS, which is not handled (and ignored) and kills the interpreter.
$ python Fatal Python error: Py_Initialize: Unable to get the locale encoding Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1558, in _find_and_load File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper File "<frozen importlib._bootstrap>", line 1023, in load_module File "<frozen importlib._bootstrap>", line 1004, in load_module File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper File "<frozen importlib._bootstrap>", line 854, in _load_module File "<frozen importlib._bootstrap>", line 990, in get_code File "<frozen importlib._bootstrap>", line 1051, in _cache_bytecode File "<frozen importlib._bootstrap>", line 1074, in set_data File "<frozen importlib._bootstrap>", line 128, in _write_atomic OSError: [Errno 30] Read-only file system: '<read-only-mount-path>/lib/python3.3/encodings/__pycache__/__init__.cpython-33.pyc.139872939267056' Aborted (core dumped) The following (hacky) patch fixes the issue for me: --- a/Python-3.3.0/Lib/importlib/_bootstrap.py +++ b/Python-3.3.0/Lib/importlib/_bootstrap.py @@ -1070,6 +1070,10 @@ class SourceFileLoader(FileLoader, SourceLoader): # If can't get proper access, then just forget about writing # the data. return + except OSError as e: + if e.errno != 30: # ignore EROFS + raise + return try: _write_atomic(path, data, _mode) _verbose_message('created {!r}', path) @@ -1077,6 +1081,9 @@ class SourceFileLoader(FileLoader, SourceLoader): # Don't worry if you can't write bytecode or someone is writing # it at the same time. pass + except OSError as e: + if e.errno != 30: # ignore EROFS + raise ---------- components: Library (Lib) messages: 172029 nosy: andrewjcg priority: normal severity: normal status: open title: Python 3.3 fails when starting from read-only FS type: behavior versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16139> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com