“PythonAccumulatorV2 does not exist” - when running SparkContext() within Jupyter Notebook












2















I recently installed Spark 2.3 on my Windows machine (with Java 8) and was able to run it via Jupyter Notebooks (Python 3).



Suddenly it stopped working - I get below error when trying to instantiate SparkContext within Notebook:



from pyspark import SparkContext
sc = pyspark.SparkContext()


Splitting the code on one-line-per-cell basis shows that it's the 2nd line that causes it.



It seems to be purely Notebook issue, as I'm still able to execute .py files with 'spark-submit' via command line.



Any idea how to fix it?



-------------------------------------------------
Py4JError Traceback (most recent call last)
<ipython-input-78-57590c71cf44> in <module>()
1 from pyspark import SparkContext
----> 2 sc = pyspark.SparkContext()

~Anaconda3libsite-packagespysparkcontext.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
116 try:
117 self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
--> 118 conf, jsc, profiler_cls)
119 except:
120 # If an error occurs, clean up in order to allow future SparkContext creation:

~Anaconda3libsite-packagespysparkcontext.py in _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, jsc, profiler_cls)
186 self._accumulatorServer = accumulators._start_update_server()
187 (host, port) = self._accumulatorServer.server_address
--> 188 self._javaAccumulator = self._jvm.PythonAccumulatorV2(host, port)
189 self._jsc.sc().register(self._javaAccumulator)
190

~Anaconda3libsite-packagespy4jjava_gateway.py in __call__(self, *args)
1523 answer = self._gateway_client.send_command(command)
1524 return_value = get_return_value(
-> 1525 answer, self._gateway_client, None, self._fqn)
1526
1527 for temp_arg in temp_args:

~Anaconda3libsite-packagespy4jprotocol.py in get_return_value(answer, gateway_client, target_id, name)
330 raise Py4JError(
331 "An error occurred while calling {0}{1}{2}. Trace:n{3}n".
--> 332 format(target_id, ".", name, value))
333 else:
334 raise Py4JError(

Py4JError: An error occurred while calling None.org.apache.spark.api.python.PythonAccumulatorV2. Trace:
py4j.Py4JException: Constructor org.apache.spark.api.python.PythonAccumulatorV2([class java.lang.String, class java.lang.Integer]) does not exist
at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:179)
at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:196)
at py4j.Gateway.invoke(Gateway.java:237)
at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
at py4j.GatewayConnection.run(GatewayConnection.java:238)
at java.lang.Thread.run(Unknown Source)









share|improve this question



























    2















    I recently installed Spark 2.3 on my Windows machine (with Java 8) and was able to run it via Jupyter Notebooks (Python 3).



    Suddenly it stopped working - I get below error when trying to instantiate SparkContext within Notebook:



    from pyspark import SparkContext
    sc = pyspark.SparkContext()


    Splitting the code on one-line-per-cell basis shows that it's the 2nd line that causes it.



    It seems to be purely Notebook issue, as I'm still able to execute .py files with 'spark-submit' via command line.



    Any idea how to fix it?



    -------------------------------------------------
    Py4JError Traceback (most recent call last)
    <ipython-input-78-57590c71cf44> in <module>()
    1 from pyspark import SparkContext
    ----> 2 sc = pyspark.SparkContext()

    ~Anaconda3libsite-packagespysparkcontext.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
    116 try:
    117 self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
    --> 118 conf, jsc, profiler_cls)
    119 except:
    120 # If an error occurs, clean up in order to allow future SparkContext creation:

    ~Anaconda3libsite-packagespysparkcontext.py in _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, jsc, profiler_cls)
    186 self._accumulatorServer = accumulators._start_update_server()
    187 (host, port) = self._accumulatorServer.server_address
    --> 188 self._javaAccumulator = self._jvm.PythonAccumulatorV2(host, port)
    189 self._jsc.sc().register(self._javaAccumulator)
    190

    ~Anaconda3libsite-packagespy4jjava_gateway.py in __call__(self, *args)
    1523 answer = self._gateway_client.send_command(command)
    1524 return_value = get_return_value(
    -> 1525 answer, self._gateway_client, None, self._fqn)
    1526
    1527 for temp_arg in temp_args:

    ~Anaconda3libsite-packagespy4jprotocol.py in get_return_value(answer, gateway_client, target_id, name)
    330 raise Py4JError(
    331 "An error occurred while calling {0}{1}{2}. Trace:n{3}n".
    --> 332 format(target_id, ".", name, value))
    333 else:
    334 raise Py4JError(

    Py4JError: An error occurred while calling None.org.apache.spark.api.python.PythonAccumulatorV2. Trace:
    py4j.Py4JException: Constructor org.apache.spark.api.python.PythonAccumulatorV2([class java.lang.String, class java.lang.Integer]) does not exist
    at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:179)
    at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:196)
    at py4j.Gateway.invoke(Gateway.java:237)
    at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
    at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
    at py4j.GatewayConnection.run(GatewayConnection.java:238)
    at java.lang.Thread.run(Unknown Source)









    share|improve this question

























      2












      2








      2


      2






      I recently installed Spark 2.3 on my Windows machine (with Java 8) and was able to run it via Jupyter Notebooks (Python 3).



      Suddenly it stopped working - I get below error when trying to instantiate SparkContext within Notebook:



      from pyspark import SparkContext
      sc = pyspark.SparkContext()


      Splitting the code on one-line-per-cell basis shows that it's the 2nd line that causes it.



      It seems to be purely Notebook issue, as I'm still able to execute .py files with 'spark-submit' via command line.



      Any idea how to fix it?



      -------------------------------------------------
      Py4JError Traceback (most recent call last)
      <ipython-input-78-57590c71cf44> in <module>()
      1 from pyspark import SparkContext
      ----> 2 sc = pyspark.SparkContext()

      ~Anaconda3libsite-packagespysparkcontext.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
      116 try:
      117 self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
      --> 118 conf, jsc, profiler_cls)
      119 except:
      120 # If an error occurs, clean up in order to allow future SparkContext creation:

      ~Anaconda3libsite-packagespysparkcontext.py in _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, jsc, profiler_cls)
      186 self._accumulatorServer = accumulators._start_update_server()
      187 (host, port) = self._accumulatorServer.server_address
      --> 188 self._javaAccumulator = self._jvm.PythonAccumulatorV2(host, port)
      189 self._jsc.sc().register(self._javaAccumulator)
      190

      ~Anaconda3libsite-packagespy4jjava_gateway.py in __call__(self, *args)
      1523 answer = self._gateway_client.send_command(command)
      1524 return_value = get_return_value(
      -> 1525 answer, self._gateway_client, None, self._fqn)
      1526
      1527 for temp_arg in temp_args:

      ~Anaconda3libsite-packagespy4jprotocol.py in get_return_value(answer, gateway_client, target_id, name)
      330 raise Py4JError(
      331 "An error occurred while calling {0}{1}{2}. Trace:n{3}n".
      --> 332 format(target_id, ".", name, value))
      333 else:
      334 raise Py4JError(

      Py4JError: An error occurred while calling None.org.apache.spark.api.python.PythonAccumulatorV2. Trace:
      py4j.Py4JException: Constructor org.apache.spark.api.python.PythonAccumulatorV2([class java.lang.String, class java.lang.Integer]) does not exist
      at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:179)
      at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:196)
      at py4j.Gateway.invoke(Gateway.java:237)
      at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
      at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Unknown Source)









      share|improve this question














      I recently installed Spark 2.3 on my Windows machine (with Java 8) and was able to run it via Jupyter Notebooks (Python 3).



      Suddenly it stopped working - I get below error when trying to instantiate SparkContext within Notebook:



      from pyspark import SparkContext
      sc = pyspark.SparkContext()


      Splitting the code on one-line-per-cell basis shows that it's the 2nd line that causes it.



      It seems to be purely Notebook issue, as I'm still able to execute .py files with 'spark-submit' via command line.



      Any idea how to fix it?



      -------------------------------------------------
      Py4JError Traceback (most recent call last)
      <ipython-input-78-57590c71cf44> in <module>()
      1 from pyspark import SparkContext
      ----> 2 sc = pyspark.SparkContext()

      ~Anaconda3libsite-packagespysparkcontext.py in __init__(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, gateway, jsc, profiler_cls)
      116 try:
      117 self._do_init(master, appName, sparkHome, pyFiles, environment, batchSize, serializer,
      --> 118 conf, jsc, profiler_cls)
      119 except:
      120 # If an error occurs, clean up in order to allow future SparkContext creation:

      ~Anaconda3libsite-packagespysparkcontext.py in _do_init(self, master, appName, sparkHome, pyFiles, environment, batchSize, serializer, conf, jsc, profiler_cls)
      186 self._accumulatorServer = accumulators._start_update_server()
      187 (host, port) = self._accumulatorServer.server_address
      --> 188 self._javaAccumulator = self._jvm.PythonAccumulatorV2(host, port)
      189 self._jsc.sc().register(self._javaAccumulator)
      190

      ~Anaconda3libsite-packagespy4jjava_gateway.py in __call__(self, *args)
      1523 answer = self._gateway_client.send_command(command)
      1524 return_value = get_return_value(
      -> 1525 answer, self._gateway_client, None, self._fqn)
      1526
      1527 for temp_arg in temp_args:

      ~Anaconda3libsite-packagespy4jprotocol.py in get_return_value(answer, gateway_client, target_id, name)
      330 raise Py4JError(
      331 "An error occurred while calling {0}{1}{2}. Trace:n{3}n".
      --> 332 format(target_id, ".", name, value))
      333 else:
      334 raise Py4JError(

      Py4JError: An error occurred while calling None.org.apache.spark.api.python.PythonAccumulatorV2. Trace:
      py4j.Py4JException: Constructor org.apache.spark.api.python.PythonAccumulatorV2([class java.lang.String, class java.lang.Integer]) does not exist
      at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:179)
      at py4j.reflection.ReflectionEngine.getConstructor(ReflectionEngine.java:196)
      at py4j.Gateway.invoke(Gateway.java:237)
      at py4j.commands.ConstructorCommand.invokeConstructor(ConstructorCommand.java:80)
      at py4j.commands.ConstructorCommand.execute(ConstructorCommand.java:69)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Unknown Source)






      python-3.x windows jupyter-notebook apache-spark-2.0






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 22:58









      Mike D.Mike D.

      384




      384
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I had the same issue, I solved it by updating my pyspark to the latest version.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421623%2fpythonaccumulatorv2-does-not-exist-when-running-sparkcontext-within-jupyte%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I had the same issue, I solved it by updating my pyspark to the latest version.






            share|improve this answer






























              0














              I had the same issue, I solved it by updating my pyspark to the latest version.






              share|improve this answer




























                0












                0








                0







                I had the same issue, I solved it by updating my pyspark to the latest version.






                share|improve this answer















                I had the same issue, I solved it by updating my pyspark to the latest version.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 29 '18 at 9:08









                blue-phoenox

                4,231101745




                4,231101745










                answered Nov 29 '18 at 8:10









                戴樂賢戴樂賢

                1




                1
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421623%2fpythonaccumulatorv2-does-not-exist-when-running-sparkcontext-within-jupyte%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    Npm cannot find a required file even through it is in the searched directory

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith