【问题标题】:Can't import sqlContext.implicits._ without an error through Jupyter无法通过 Jupyter 导入 sqlContext.implicits._ 而不会出错
【发布时间】:2016-06-13 20:33:16
【问题描述】:

当我尝试在 Jupyter 笔记本上使用 import sqlContext.implicits._ 时,出现以下错误:

Name: Compile Error
Message: <console>:25: error: stable identifier required, but $iwC.this.$VAL10.sqlContext.implicits found.
       import sqlContext.implicits._
                         ^

我已经在本地尝试过,它可以工作,但是在我的 Jupyter Notebook 服务器(托管在 ec2 上)上使用它时无法正常工作。我曾尝试导入涉及该功能的不同库,但遗憾的是无法使其正常运行。

【问题讨论】:

    标签: scala apache-spark amazon-ec2 apache-spark-sql jupyter


    【解决方案1】:

    你需要像这样实例化一个 sqlContext:

    val sqlC = new org.apache.spark.sql.SQLContext(sc)
    import sqlC.implicits._
    

    你应该已经看到了这个错误:

    需要稳定的标识符

    【讨论】:

      【解决方案2】:

      您必须使用 val 关键字而不是 var 关键字。因为val 等于constfinal 关键字。

      【讨论】:

        猜你喜欢
        • 2016-04-23
        • 1970-01-01
        • 2022-01-12
        • 1970-01-01
        • 2023-04-11
        • 1970-01-01
        • 2021-07-04
        • 2019-06-11
        • 2021-09-24
        相关资源
        最近更新 更多