【发布时间】:2018-03-16 13:16:09
【问题描述】:
我正在尝试安装 Parquet 文件格式以将其与 Apache Spark 一起使用。我了解到我必须安装 Thrift、ThriftPy 和 Python-Snappy 才能完全安装 Parquet。
我使用命令安装 Thrift
pip install thrift
然后我通过找到here 的轮文件手动安装了 python-snappy。这是因为我无法自动安装 python-snappy。无论如何,python-snappy 安装成功。
我也使用类似的命令安装了 ThrifPy
pip install ThriftPy
最后,我使用 pip 安装了 parquet,成功了。安装后,当我尝试导入镶木地板时,它会引发错误为
---------------------------------------------------------------------------
ThriftParserError Traceback (most recent call last)
<ipython-input-55-942008defa53> in <module>()
----> 1 import parquet
C:\anaconda2\lib\site-packages\parquet\__init__.py in <module>()
17 from thriftpy.protocol.compact import TCompactProtocolFactory
18
---> 19 from . import encoding
20 from . import schema
21 from .converted_types import convert_column
C:\anaconda2\lib\site-packages\parquet\encoding.py in <module>()
17
18 THRIFT_FILE = os.path.join(os.path.dirname(__file__), "parquet.thrift")
---> 19 parquet_thrift = thriftpy.load(THRIFT_FILE,
module_name=str("parquet_thrift")) # pylint: disable=invalid-name
20
21 logger = logging.getLogger("parquet") # pylint: disable=invalid-name
C:\anaconda2\lib\site-packages\thriftpy\parser\__init__.pyc in load(path,
module_name, include_dirs, include_dir)
28 real_module = bool(module_name)
29 thrift = parse(path, module_name, include_dirs=include_dirs,
---> 30 include_dir=include_dir)
31
32 if real_module:
C:\anaconda2\lib\site-packages\thriftpy\parser\parser.pyc in parse(path,
module_name, include_dirs, include_dir, lexer, parser, enable_cache)
494 raise ThriftParserError('ThriftPy does not support generating
module '
495 'with path in protocol \'{}\''.format(
--> 496 url_scheme))
497
498 if module_name is not None and not module_name.endswith('_thrift'):
ThriftParserError: ThriftPy does not support generating module with path in
protocol 'c'
有人能告诉我我做错了什么吗?
作为参考,我在 Jupyter 笔记本上使用 anaconda Python 2.7。我的操作系统是 Windows 7 ,我在单个集群上使用 Spark。
【问题讨论】:
-
Python
parquet包已过时,请尝试使用pyarrow读取Apache Parquet 文件:arrow.apache.org/docs/python/parquet.html -
非常感谢...但是pyarrow只适用于Python 3.5或更高版本..目前我的老板不允许我转换到Python 3.5,所以我不能使用它。 ..Python 2.7 有解决方案吗?再次感谢
-
由于 Windows 上可用 Python 构建的性质,遗憾的是只能在 Windows 上使用 3.5+ 构建。如果您想在较旧的 Python 中使用
pyarrow,则需要使用 Linux 或 OSX。
标签: python-2.7 apache-spark parquet