How to fix "ImportError: PyArrow >= 0.8.0 must be installed; however, it was not found."?
How to fix "ImportError: PyArrow >= 0.8.0 must be installed; however, it was not found."?
我使用 PySpark 2.4.0,当我在 pyspark
中执行以下代码时:
$ ./bin/pyspark
Python 2.7.16 (default, Mar 25 2019, 15:07:04)
...
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 2.4.0
/_/
Using Python version 2.7.16 (default, Mar 25 2019 15:07:04)
SparkSession available as 'spark'.
>>> from pyspark.sql.functions import pandas_udf
>>> from pyspark.sql.functions import pandas_udf, PandasUDFType
>>> from pyspark.sql.types import IntegerType, StringType
>>> slen = pandas_udf(lambda s: s.str.len(), IntegerType())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/x/spark/python/pyspark/sql/functions.py", line 2922, in pandas_udf
return _create_udf(f=f, returnType=return_type, evalType=eval_type)
File "/Users/x/spark/python/pyspark/sql/udf.py", line 47, in _create_udf
require_minimum_pyarrow_version()
File "/Users/x/spark/python/pyspark/sql/utils.py", line 149, in require_minimum_pyarrow_version
"it was not found." % minimum_pyarrow_version)
ImportError: PyArrow >= 0.8.0 must be installed; however, it was not found.
如何解决?
本例中的错误消息具有误导性,pyarrow
未安装。
来自官方文档Spark SQL Guide (that led to Installing PyArrow),你应该简单地执行以下命令之一:
$ conda install -c conda-forge pyarrow
或
$ pip install pyarrow
在适当的用户和 Python 版本下 运行 它也很重要。即,如果在 Python3 根目录下使用 Zeppelin,则可能需要执行
# pip3 install pyarrow
改为
重新安装 pyarrow
对我有用:
$ pip uninstall pyarrow -y
$ pip install pyarrow
然后重启内核。
我也有这个问题,后来发现是虚拟环境的问题
所以我运行:
conda deactivate
conda activate <NAME_OF_VENV>
然后就可以正常安装了
我在 pyarrow
使用 Spark 2.3 时遇到同样的问题。
以下解决了我的问题:
卸载pandas 因为我的是为了 deb9 包
sudo apt-get remove python-pandas
安装 pandas (pandas (0.24.2)
)
sudo pip install pandas
安装 pyarrow (pyarrow (0.16.0)
):
sudo pip install pyarrow
将以下内容添加到spark-env.sh
ARROW_PRE_0_15_IPC_FORMAT=1
重启所有工人和主人
运行 pyspark
我遇到了这个问题,但可能与你的问题无关。情况是,我使用 vscode 作为我的 IDE,而 anaconda 作为我的 python 编译器。当我 运行 我的代码时,此通知会显示在那里。我通过在我的基本环境中安装 pyarrow 来解决这个问题。在此之前,我只在我的 pyspark 虚拟环境中安装了 pyarrow
我使用 PySpark 2.4.0,当我在 pyspark
中执行以下代码时:
$ ./bin/pyspark
Python 2.7.16 (default, Mar 25 2019, 15:07:04)
...
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 2.4.0
/_/
Using Python version 2.7.16 (default, Mar 25 2019 15:07:04)
SparkSession available as 'spark'.
>>> from pyspark.sql.functions import pandas_udf
>>> from pyspark.sql.functions import pandas_udf, PandasUDFType
>>> from pyspark.sql.types import IntegerType, StringType
>>> slen = pandas_udf(lambda s: s.str.len(), IntegerType())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/x/spark/python/pyspark/sql/functions.py", line 2922, in pandas_udf
return _create_udf(f=f, returnType=return_type, evalType=eval_type)
File "/Users/x/spark/python/pyspark/sql/udf.py", line 47, in _create_udf
require_minimum_pyarrow_version()
File "/Users/x/spark/python/pyspark/sql/utils.py", line 149, in require_minimum_pyarrow_version
"it was not found." % minimum_pyarrow_version)
ImportError: PyArrow >= 0.8.0 must be installed; however, it was not found.
如何解决?
本例中的错误消息具有误导性,pyarrow
未安装。
来自官方文档Spark SQL Guide (that led to Installing PyArrow),你应该简单地执行以下命令之一:
$ conda install -c conda-forge pyarrow
或
$ pip install pyarrow
在适当的用户和 Python 版本下 运行 它也很重要。即,如果在 Python3 根目录下使用 Zeppelin,则可能需要执行
# pip3 install pyarrow
改为
重新安装 pyarrow
对我有用:
$ pip uninstall pyarrow -y
$ pip install pyarrow
然后重启内核。
我也有这个问题,后来发现是虚拟环境的问题
所以我运行:
conda deactivate
conda activate <NAME_OF_VENV>
然后就可以正常安装了
我在 pyarrow
使用 Spark 2.3 时遇到同样的问题。
以下解决了我的问题:
卸载pandas 因为我的是为了 deb9 包
sudo apt-get remove python-pandas
安装 pandas (
pandas (0.24.2)
)sudo pip install pandas
安装 pyarrow (
pyarrow (0.16.0)
):sudo pip install pyarrow
将以下内容添加到
spark-env.sh
ARROW_PRE_0_15_IPC_FORMAT=1
重启所有工人和主人
运行
pyspark
我遇到了这个问题,但可能与你的问题无关。情况是,我使用 vscode 作为我的 IDE,而 anaconda 作为我的 python 编译器。当我 运行 我的代码时,此通知会显示在那里。我通过在我的基本环境中安装 pyarrow 来解决这个问题。在此之前,我只在我的 pyspark 虚拟环境中安装了 pyarrow