Python OSError: Bad address when reading from large file

送分小仙女□ 提交于 2020-01-24 09:50:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!