在 AIX Python 2.6.2 上打开 4GB+ 文件时,我收到 IOError:
>>> fd = open('/mnt/t/MY_BIG_4GB_FILE', 'r')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 127] Value too large to be stored in data type: '/mnt/t/MY_BIG_4GB_FILE'
有什么解决办法吗?我在 Google 中没有找到信息。
编辑: 为了读取大文件,我做了一些事情(我知道这是垃圾,但有时你根本无法更改 python 版本):
from subprocess import Popen, PIPE
p = Popen(["cat", source_file], stdout=PIPE, bufsize=BUFFER_SIZE)
try:
for line in iter(p.stdout.readline, ''):
# process line
pass
finally:
p.communicate() # closing Popen
最佳答案
您正在寻找“大文件支持”。这里有一个不错的简介:http://docs.python.org/2/library/posix.html#large-file-support 。您可能需要使用适当的选项重新编译 Python 解释器,或者找到一个具有这些选项的预构建解释器。如果可以的话,尝试构建 Python 2.7。
关于Python 2.6 : Opening 4GB file throws "IOError: [Errno 127] Value too large to be stored in data type" on AIX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21704904/