[英]python 3 mac: snappy.compress AttributeError: module 'snappy' has no attribute 'compress'
Has anyone solved the error: message: compressions['SNAPPY'] = snappy.compress AttributeError: module 'snappy' has no attribute 'compress'
when reading parquet in python?有没有人解决了这个错误:message:
compressions['SNAPPY'] = snappy.compress AttributeError: module 'snappy' has no attribute 'compress'
when reading parquet in python? Btw, is there a way to read whole dir?顺便说一句,有没有办法读取整个目录?
I am using python 3
through conda
on mac with snappy
and thrift
installed as per https://pypi.python.org/pypi/parquet
我正在通过 Mac 上的
conda
使用python 3
,并按照https://pypi.python.org/pypi/parquet
安装了snappy
和thrift
code as follows:代码如下:
import parquet
import json
import fastparquet
with open(data_in_path + "file.parquet/part-01snappy.parquet", 'rb') as fo:
for row in parquet.DictReader(fo, columns=['id', 'title']):
print(json.dumps(row))
or或者
df2 = fastparquet.ParquetFile(path).to_pandas()
I had the same issue.我遇到过同样的问题。
The reason was I installed the wrong python package.原因是我安装了错误的python包。 You should install
python-snappy
instead of snappy
你应该安装
python-snappy
而不是snappy
In my case (os x), it was a simple, two step process:在我的情况下(os x),这是一个简单的两步过程:
brew install snappy
pip install python-snappy
无法找到snappy
解决方案,所以我用snappy
在spark
读取数据,并在发现 python 中的每个问题后用gzip
将其写回:
df.coalesce(1).write.option("overwrite","true").option("compression","gzip").parquet(dfWithGzip.parquet")
I was experiencing the same issue. 我遇到了同样的问题。 uninstalling and reinstalling as @Javier Alba specified, it worked for me.
按照@Javier Alba的指示进行卸载和重新安装,它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.