2016-07-04 2 views
0

誰でもこのエラーの原因を知っていますか?基本的に見えます。スパークset_hadoop_configエラー

def set_hadoop_config(credentials): 
prefix = "fs.swift.service." + credentials['name'] 
hconf = sc._jsc.hadoopConfiguration() 
hconf.set(prefix + ".auth.url", credentials['auth_url']+'/v2.0/tokens') 
hconf.set(prefix + ".auth.endpoint.prefix", "endpoints") 
hconf.set(prefix + ".tenant", credentials['project_id']) 
hconf.set(prefix + ".username", credentials['user_id']) 
hconf.set(prefix + ".password", credentials['password']) 
hconf.setInt(prefix + ".http.port", 8080) 
hconf.set(prefix + ".region", credentials['region']) 

アウト:で

Name: Compile Error Message: :1: error: ':' expected but ')' found. def set_hadoop_config(credentials): ^StackTrace:

ありがとう!

+0

は、構文エラーのようですね。コード内のどこかに、コロンを置いたときにかっこを入れました。 –

+0

これは新しいノートブックであり、残念なことに1行目のコードです。 Thx – Tak

+0

あなたの質問に示されているようにコードを実行すると、2行目にインデントがないというエラーが表示されます。最初の行以外のすべてをインデントすると、問題なく実行されます。私は新しく作られたノートを試しました。 実際のコードで見落とした空白やその他の特殊文字がありますか? –

答えて

0

このコードには2つの問題があります。

  1. これはPythonコードスニペットですが、有効なScalaコードを要求するScala Kernel内で実行されます。カーネルを切り替えるには、Kernel-> Change Kernelメニューオプションを使用します。これはあなたが見ているCompileErrorの理由です。

  2. 関数本体が正しくインデントされていないため、Pythonカーネルで実行すると、IndentationErrorが返されます。代わりに使用します。


    def set_hadoop_config(credentials): 
     prefix = "fs.swift.service." + credentials['name'] 
     hconf = sc._jsc.hadoopConfiguration() 
     hconf.set(prefix + ".auth.url", credentials['auth_url']+'/v2.0/tokens') 
     hconf.set(prefix + ".auth.endpoint.prefix", "endpoints") 
     hconf.set(prefix + ".tenant", credentials['project_id']) 
     hconf.set(prefix + ".username", credentials['user_id']) 
     hconf.set(prefix + ".password", credentials['password']) 
     hconf.setInt(prefix + ".http.port", 8080) 
     hconf.set(prefix + ".region", credentials['region']) 

(ヒント:ノートブックでは、完全な関数本体を選択し、それをインデントする一度Tabを打つ)