问题
I am observing a "Bad address" OSError when reading from a file handle created using the with syntax in Python 3.
The file in question is 39G, but I should have enough RAM available to read the whole file. The error message leads me to believe I am hitting some kind of OS restriction; I am running CentOS 6.9. Can anyone help me understand what might be causing this behavior?
The file is perfectly readable outside of python, e.g. in bash with head or vim.
Simplified code sample producing the error is shown below:
In [2]: with open(filename, 'r', encoding="utf8") as infile:
...: infile.read()
...:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-2-3f216811bec7> in <module>()
1 with open(filename, 'r', encoding="utf8") as infile:
----> 2 infile.read()
3
OSError: [Errno 14] Bad address
来源:https://stackoverflow.com/questions/50634054/python-oserror-bad-address-when-reading-from-large-file