我想使用pyspark在本地计算机上运行Spark。从here我使用命令:
sbt/sbt assembly
$ ./bin/pyspark
安装完成,但pyspark无法运行,导致以下错误(完整):
138:spark-0.9.1 comp_name$ ./bin/pyspark
Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "/Users/comp_name/Downloads/spark-0.9.1/python/pyspark/shell.py", line 32, in <module>
sc = SparkContext(os.environ.get("MASTER", "local"), "PySparkShell", pyFiles=add_files)
File "/Users/comp_name/Downloads/spark-0.9.1/python/pyspark/context.py", line 123, in __init__
self._jsc = self._jvm.JavaSparkContext(self._conf._jconf)
File "/Users/comp_name/Downloads/spark-0.9.1/python/lib/py4j-0.8.1-src.zip/py4j/java_gateway.py", line 669, in __call__
File "/Users/comp_name/Downloads/spark-0.9.1/python/lib/py4j-0.8.1-src.zip/py4j/protocol.py", line 300, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling None.org.apache.spark.api.java.JavaSparkContext.
: java.net.UnknownHostException: 138.7.100.10.in-addr.arpa: 138.7.100.10.in-addr.arpa: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1466)
at org.apache.spark.util.Utils$.findLocalIpAddress(Utils.scala:355)
at org.apache.spark.util.Utils$.localIpAddress$lzycompute(Utils.scala:347)
at org.apache.spark.util.Utils$.localIpAddress(Utils.scala:347)
at org.apache.spark.util.Utils$.localIpAddressHostname$lzycompute(Utils.scala:348)
at org.apache.spark.util.Utils$.localIpAddressHostname(Utils.scala:348)
at org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:395)
at org.apache.spark.util.Utils$$anonfun$localHostName$1.apply(Utils.scala:395)
at scala.Option.getOrElse(Option.scala:120)
at org.apache.spark.util.Utils$.localHostName(Utils.scala:395)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:124)
at org.apache.spark.api.java.JavaSparkContext.<init>(JavaSparkContext.scala:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:234)
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:379)
at py4j.Gateway.invoke(Gateway.java:214)
at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:79)
at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:68)
at py4j.GatewayConnection.run(GatewayConnection.java:207)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.net.UnknownHostException: 138.7.100.10.in-addr.arpa: nodename nor servname provided, or not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1286)
at java.net.InetAddress.getLocalHost(InetAddress.java:1462)
... 22 more
任何想法我做错了什么?我不知道IP地址138.7.100.10
的来源。
使用(或不使用)MAMP创建localhost时出现此错误。
提前谢谢!
答案 0 :(得分:11)
正确的解决方案是将SPARK_LOCAL_IP环境变量设置为localhost或您的主机名。
答案 1 :(得分:5)
我遇到了与Spark相同的问题,它与您的笔记本电脑IP有关。
我的解决方案:
sudo / etc / hosts
以下
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
添加
127.0.0.1 LAPTOPNAME
你的LAPTOPNAME可以在你的终端上找到它 root @LAPTOPNAME(在安装过程中设置的任何一个)
它将与Java1.7一起运行
答案 2 :(得分:4)
我发现,我使用的Java版本是1.7。 我正在使用Macbook Air,运行10.9.2
$ java -version
给了我:
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
要降级到1.6:
$ cd /Library/Java/JavaVirtualMachines
$ ls
返回:
jdk1.7.0_25.jdk
要删除该文件(并降级java并修复我的问题):
$ sudo rm -rf jdk1.7.0_25.jdk
然后我有:
$ java -version
给出了输出:
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
最后,我能够运行Spark:
$ ./bin/pyspark
一切都很开心:
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 0.9.1
/_/