我正在尝试运行simple Graphframes example。我同时拥有Python 3.6.8和Python 2.7.15,以及Apache Maven 3.6.0,Java 1.8.0,Apache Spark 2.4.4和Scala代码运行器版本2.11.12。

我收到此错误:

An error occurred while calling o58.loadClass.
: java.lang.ClassNotFoundException: org.graphframes.GraphFramePythonAPI


我试图使this solution处于运动状态,但是我陷入了第2步。

我运行pyspark --packages graphframes:graphframes:0.7.0-spark2.4-s_2.11并得到以下输出:

Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Ivy Default Cache set to: /home/jessica/.ivy2/cache
The jars for the packages stored in: /home/jessica/.ivy2/jars
:: loading settings :: url = jar:file:/usr/local/spark/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
graphframes#graphframes added as a dependency
:: resolving dependencies :: org.apache.spark#spark-submit-parent-1be543dc-eac1-4324-bef5-4bab70bd9c95;1.0
    confs: [default]
downloading file:/home/jessica/.m2/repository/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11.jar ..
    [SUCCESSFUL ] graphframes#graphframes;0.7.0-spark2.4-s_2.11!graphframes.jar (18ms)
downloading file:/home/jessica/.m2/repository/org/slf4j/slf4j-api/1.7.16/slf4j-api-1.7.16.jar ...
    [SUCCESSFUL ] org.slf4j#slf4j-api;1.7.16!slf4j-api.jar (13ms)
:: resolution report :: resolve 786773ms :: artifacts dl 67ms
    :: modules in use:
    graphframes#graphframes;0.7.0-spark2.4-s_2.11 from local-m2-cache in [default]
    org.slf4j#slf4j-api;1.7.16 from spark-list in [default]
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |   2   |   1   |   1   |   0   ||   2   |   2   |
    ---------------------------------------------------------------------

:: problems summary ::
:::: ERRORS
    Server access error at url https://repo1.maven.org/maven2/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11-sources.jar (java.net.ConnectException: Connection timed out (Connection timed out))

    Server access error at url https://dl.bintray.com/spark-packages/maven/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11-sources.jar (java.net.ConnectException: Connection timed out (Connection timed out))

    Server access error at url https://repo1.maven.org/maven2/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11-src.jar (java.net.ConnectException: Connection timed out (Connection timed out))

    Server access error at url https://dl.bintray.com/spark-packages/maven/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11-src.jar (java.net.ConnectException: Connection timed out (Connection timed out))

    Server access error at url https://repo1.maven.org/maven2/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11-javadoc.jar (java.net.ConnectException: Connection timed out (Connection timed out))

    Server access error at url https://dl.bintray.com/spark-packages/maven/graphframes/graphframes/0.7.0-spark2.4-s_2.11/graphframes-0.7.0-spark2.4-s_2.11-javadoc.jar (java.net.ConnectException: Connection timed out (Connection timed out))

    unknown resolver sbt-chain

    unknown resolver null


:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
:: retrieving :: org.apache.spark#spark-submit-parent-1a173e58-c356-43d7-9112-b06817ef3674
    confs: [default]
    2 artifacts copied, 0 already retrieved (411kB/27ms)
he19/10/25 10:39:01 WARN Utils: Your hostname, jessica-VirtualBox resolves to a loopback address: 127.0.1.1; using 10.0.2.15 instead (on interface enp0s3)
19/10/25 10:39:01 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
lp19/10/25 10:39:02 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
Exception in thread "main" java.nio.file.NoSuchFileException: /tmp/tmp6pP3C_/connection6206654157170594455.info
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.createFile(Files.java:632)
    at java.nio.file.TempFileHelper.create(TempFileHelper.java:138)
    at java.nio.file.TempFileHelper.createTempFile(TempFileHelper.java:161)
    at java.nio.file.Files.createTempFile(Files.java:852)
    at org.apache.spark.api.python.PythonGatewayServer$.main(PythonGatewayServer.scala:70)
    at org.apache.spark.api.python.PythonGatewayServer.main(PythonGatewayServer.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.spark.deploy.JavaMainApplication.start(SparkApplication.scala:52)
    at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:845)
    at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:161)
    at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:184)
    at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:86)
    at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:920)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:929)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)


不用说这不是预期的输出,所有超时的链接都导致404。我的电脑在代理后面,但是代理设置是在Maven设置文件中配置的,我知道它们可以正常工作。

还有其他代理设置需要更改吗?也许还有另一种方法来安装这些依赖项?

编辑

我将/usr/share/jupyter/kernels/python3/kernel.json文件更改为:

{
 "argv": [
  "/usr/bin/python3",
  "-m",
  "ipykernel_launcher",
  "-f",
  "{connection_file}"
 ],
 "env": {
  "PYSPARK_SUBMIT_ARGS": "--packages graphframes:graphframes:0.7.0-spark2.4-s_2.11 --master local[10] pyspark-shell"
 },
 "display_name": "Python 3",
 "language": "python"
}


然后尝试在Jupyter Notebook中运行我的Python脚本。这没有用。实际上,现在我运行Python脚本后就立即导致此错误(在导入所需的导入后,它崩溃了)

编辑2

我调整了Firefox并自己下载了文件。

-rw-rw-r-- 1 jessica jessica   381110 Oct 22 12:17 graphframes-0.7.0-spark2.4-s_2.11.jar
-rw-rw-r-- 1 jessica jessica     2541 Oct 22 12:14 graphframes-0.7.0-spark2.4-s_2.11.pom


然后,我运行了mvn install:install-file -Dfile=graphframes-0.7.0-spark2.4-s_2.11.jar -DpomFile=graphframes-0.7.0-spark2.4-s_2.11.pom,尽管该过程成功完成,但我仍然无法运行脚本(出于同样的原因)。但是,我的maven存储库中现在有一个graphframes文件夹,其中包含所有必需的文件。

编辑3

我已经卸载并重新安装了Jupyter,notebook,graphframes,toree,iPython,并添加了Anaconda-全部用于Python 2.7和Python3。我无法为Python / Pyspark安装Apache Toree内核(v0.3.0)(我确实有SQL)和Scala,显然不再支持它的Python / Pyspark内核-也欢迎提供解决方案)。

我的SPARK_HOME=~/spark/spark-2.2.0-bin-hadoop2.7变量以及PYSPARK_DRIVER_PYTHON="jupyter"PYSPARK_DRIVER_PYTHON_OPTS="notebook"也已设置。

最佳答案

我使用advice from this site解决了问题。

长话短说,将罐子直接放入$SPARK_HOME/jars

10-05 22:48