我正在使用来自jupyter的pyspark和graphframes。我能够成功导入pyspark和graphframes,但是当我尝试时:
from graphframes.lib import Pregel
我收到以下错误:
ImportError: cannot import name 'Pregel' from 'graphframes.lib'
这篇文章是我如何使图框工作,但没有graphframes.lib的方式:
https://github.com/graphframes/graphframes/issues/104
wget https://github.com/graphframes/graphframes/archive/release-0.2.0.zip
unzip release-0.2.0.zip
cd graphframes-release-0.2.0
build/sbt assembly
cd ..
# Copy necessary files to root level so we can start pyspark.
cp graphframes-release-0.2.0/target/scala-2.11/graphframes-release-0-2-0-assembly-0.2.0-spark2.0.jar .
cp -r graphframes-release-0.2.0/python/graphframes .
# Set environment to use Jupyter
export PYSPARK_DRIVER_PYTHON=jupyter
export PYSPARK_DRIVER_PYTHON_OPTS=notebook
# Launch the jupyter server.
pyspark --jars graphframes-release-0-2-0-assembly-0.2.0-spark2.0.jar
我尝试重复上述命令,没有环境行,因为pyspark在jupyter中使用其他版本对我来说很好用,并且能够获取graphframes.lib,但没有Pregel:
wget https://github.com/graphframes/graphframes/archive/release-0.6.0.zip
unzip release-0.6.0.zip
cd graphframes-release-0.6.0
build/sbt assembly
cd ..
# Copy necessary files to root level so we can start pyspark.
cp graphframes-release-0.6.0/target/scala-2.11/graphframes-assembly-0.6.0-spark2.3.jar .
cp -r graphframes-release-0.6.0/python/graphframes .
# Set environment to use Jupyter
export PYSPARK_DRIVER_PYTHON=jupyter
export PYSPARK_DRIVER_PYTHON_OPTS=notebook
# Launch the jupyter server.
pyspark --jars graphframes-assembly-0.6.0-spark2.3.jar
现在,我可以看到graphrames.lib目录,但其中只有aggregate_messages.py。
最后,我尝试了以下操作,但收到404错误:
wget https://github.com/graphframes/graphframes/archive/release-0.7.0.zip
我希望,因为我能够导入图框,所以能够从graphframes.lib导入Pregel。在我的0.6.0版本中,似乎有一个graphrames.lib但没有Pregel,并且没有针对图框的0.7.0版本。
答案 0 :(得分:0)
我能够使用以下方法解决此错误:
wget https://github.com/graphframes/graphframes/archive/f9e13ab4ac1a7113f8439744a1ab45710eb50a72.zip
unzip graphframes-f9e13ab4ac1a7113f8439744a1ab45710eb50a72.zip
cd graphframes-f9e13ab4ac1a7113f8439744a1ab45710eb50a72
build/sbt assembly
cd ..
# Copy necessary files to root level so we can start pyspark.
cp graphframes-f9e13ab4ac1a7113f8439744a1ab45710eb50a72/target/scala-2.11/graphframes-assembly-0.7.0-spark2.4.jar .
cp -r graphframes-f9e13ab4ac1a7113f8439744a1ab45710eb50a72/python/graphframes .
# Set environment to use Jupyter (if jupyter working with pyspark, skip)
# export PYSPARK_DRIVER_PYTHON=jupyter
# export PYSPARK_DRIVER_PYTHON_OPTS=notebook
# launch pyspark
pyspark --jars graphframes-assembly-0.7.0-spark2.4.jar