下面的函數基於the Python gzip module docs中的Python示例代碼。它使用默認的Python 2.6.x在Ubuntu 10.04上可靠地運行。但是,在Ubuntu 11.04上,代碼失敗@writelines()
。Ubuntu上的Python gzip失敗11.04
在一臺11.04機器上,故障信息報告爲'module' object has no attribute 'BufferedIOBase'
。另一臺11.04機器報告了不同的信息No module named numpy
。然而,numpy軟件包安裝在兩臺機器上。
有誰知道任何缺失的Python依賴關係或其他問題在11.04會導致這種情況?
def _compress(inp,out):
import gzip
f_out = gzip.open(out,'wb')
f_in = open(inp,'rb')
f_out.writelines(f_in)
f_out.close()
f_in.close()
os.unlink(inp)
可能重複[如何導入的igraph時解決AttributeError的?](http://stackoverflow.com/questions/6315440/how-to-solve-attributeerror-when- imported-igraph) – krock
'numpy'與'gzip'有什麼關係?你可能在錯誤的地方尋找你的錯誤。 – vartec
你有沒有'io.py'文件,或者'io/__ init __。py'可能會被導入? –