title: How configure PySpark in PyCharm? I have a problem
body: <p>I have problem to configure PySpark in PyCharm.
  I use: Java JDK 1.0_311, Python 3.10.1, spark-3.2.0-bin-hadoop3.2. I followed this tutorial: <a href="https://kaizen.itversity.com/setup-spark-development-environment-pycharm-and-python/" rel="nofollow noreferrer">https://kaizen.itversity.com/setup-spark-development-environment-pycharm-and-python/</a></p>
  <p>My code is:</p>
  <pre><code>from pyspark.sql import SparkSession
  
  spark=SparkSession.builder.master(&quot;local[*]&quot;).appName(&quot;SparkExamples.com&quot;).getOrCreate()
  
  rdd=spark.sparkContext.parallelize([1,2,3,4,5,6])
  
  print(rdd.count())
  
  </code></pre>
  <p>This is the error:</p>
  <pre><code>Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
  Setting default log level to &quot;WARN&quot;.
  To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
  22/01/07 22:04:33 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
  Python not finded; Esegui senza argomenti per installare da Microsoft Store o disabilitare il collegamento da impostazioni &gt; Gestisci app Alias di esecuzione.
  22/01/07 22:04:46 WARN ProcfsMetricsGetter: Exception when trying to compute pagesize, as a result reporting of ProcessTree metrics is stopped
  22/01/07 22:04:49 ERROR Executor: Exception in task 3.0 in stage 0.0 (TID 3)
  org.apache.spark.SparkException: Python worker failed to connect back.
      at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:188)
      at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:108)
      at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:121)
      at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:162)
      at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
      at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:373)
      at org.apache.spark.rdd.RDD.iterator(RDD.scala:337)
      at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
      at org.apache.spark.scheduler.Task.run(Task.scala:131)
      at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:506)
      at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1462)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:509)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.net.SocketTimeoutException: Accept timed out
      at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
      at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
      at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:535)
      at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:189)
      at java.net.ServerSocket.implAccept(ServerSocket.java:545)
      at java.net.ServerSocket.accept(ServerSocket.java:513)
      at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:175)
      ... 14 more
  22/01/07 22:04:49 WARN TaskSetManager: Lost task 3.0 in stage 0.0 (TID 3) (Domenico-PC executor driver): org.apache.spark.SparkException: Python worker failed to connect back.
      at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:188)
      at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:108)
      at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:121)
      at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:162)
      at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
      at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:373)
      at org.apache.spark.rdd.RDD.iterator(RDD.scala:337)
      at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
      at org.apache.spark.scheduler.Task.run(Task.scala:131)
      at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:506)
      at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1462)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:509)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: java.net.SocketTimeoutException: Accept timed out
      at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
      at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
      at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:535)
      at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:189)
      at java.net.ServerSocket.implAccept(ServerSocket.java:545)
      at java.net.ServerSocket.accept(ServerSocket.java:513)
      at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:175)
      ... 14 more
  </code></pre>
  <p>22/01/07 22:04:49 ERROR TaskSetManager: Task 3 in stage 0.0 failed 1 times; aborting job
  Traceback (most recent call last):
  File &quot;C:\Users\domen\PycharmProjects\pythonProject16\main.py&quot;, line 7, in 
  print(rdd.count())
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\pyspark.zip\pyspark\rdd.py&quot;, line 1237, in count
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\pyspark.zip\pyspark\rdd.py&quot;, line 1226, in sum
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\pyspark.zip\pyspark\rdd.py&quot;, line 1080, in fold
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\pyspark.zip\pyspark\rdd.py&quot;, line 950, in collect
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\py4j-0.10.9.2-src.zip\py4j\java_gateway.py&quot;, line 1309, in <strong>call</strong>
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\pyspark.zip\pyspark\sql\utils.py&quot;, line 111, in deco
  File &quot;C:\Users\domen\spark-3.2.0-bin-hadoop3.2\python\lib\py4j-0.10.9.2-src.zip\py4j\protocol.py&quot;, line 326, in get_return_value
  py4j.protocol.Py4JJavaError: An error occurred while calling z:org.apache.spark.api.python.PythonRDD.collectAndServe.
  : org.apache.spark.SparkException: Job aborted due to stage failure: Task 3 in stage 0.0 failed 1 times, most recent failure: Lost task 3.0 in stage 0.0 (TID 3) (Domenico-PC executor driver): org.apache.spark.SparkException: Python worker failed to connect back.
  at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:188)
  at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:108)
  at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:121)
  at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:162)
  at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
  at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:373)
  at org.apache.spark.rdd.RDD.iterator(RDD.scala:337)
  at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
  at org.apache.spark.scheduler.Task.run(Task.scala:131)
  at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:506)
  at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1462)
  at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:509)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  at java.lang.Thread.run(Thread.java:748)
  Caused by: java.net.SocketTimeoutException: Accept timed out
  at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
  at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
  at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:535)
  at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:189)
  at java.net.ServerSocket.implAccept(ServerSocket.java:545)
  at java.net.ServerSocket.accept(ServerSocket.java:513)
  at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:175)
  ... 14 more</p>
  <p>Driver stacktrace:
  at org.apache.spark.scheduler.DAGScheduler.failJobAndIndependentStages(DAGScheduler.scala:2403)
  at org.apache.spark.scheduler.DAGScheduler.$anonfun$abortStage$2(DAGScheduler.scala:2352)
  at org.apache.spark.scheduler.DAGScheduler.$anonfun$abortStage$2$adapted(DAGScheduler.scala:2351)
  at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62)
  at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55)
  at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49)
  at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:2351)
  at org.apache.spark.scheduler.DAGScheduler.$anonfun$handleTaskSetFailed$1(DAGScheduler.scala:1109)
  at org.apache.spark.scheduler.DAGScheduler.$anonfun$handleTaskSetFailed$1$adapted(DAGScheduler.scala:1109)
  at scala.Option.foreach(Option.scala:407)
  at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:1109)
  at</p>
  <pre><code>org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:2591)
      at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:2533)
      at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:2522)
      at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:49)
      at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:898)
      at org.apache.spark.SparkContext.runJob(SparkContext.scala:2214)
      at org.apache.spark.SparkContext.runJob(SparkContext.scala:2235)
      at org.apache.spark.SparkContext.runJob(SparkContext.scala:2254)
      at org.apache.spark.SparkContext.runJob(SparkContext.scala:2279)
      at org.apache.spark.rdd.RDD.$anonfun$collect$1(RDD.scala:1030)
      at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
      at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
      at org.apache.spark.rdd.RDD.withScope(RDD.scala:414)
      at org.apache.spark.rdd.RDD.collect(RDD.scala:1029)
      at org.apache.spark.api.python.PythonRDD$.collectAndServe(PythonRDD.scala:180)
      at org.apache.spark.api.python.PythonRDD.collectAndServe(PythonRDD.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 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
      at py4j.Gateway.invoke(Gateway.java:282)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.ClientServerConnection.waitForCommands(ClientServerConnection.java:182)
      at py4j.ClientServerConnection.run(ClientServerConnection.java:106)
      at java.lang.Thread.run(Thread.java:748)
  Caused by: org.apache.spark.SparkException: Python worker failed to connect back.
      at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:188)
      at org.apache.spark.api.python.PythonWorkerFactory.create(PythonWorkerFactory.scala:108)
      at org.apache.spark.SparkEnv.createPythonWorker(SparkEnv.scala:121)
      at org.apache.spark.api.python.BasePythonRunner.compute(PythonRunner.scala:162)
      at org.apache.spark.api.python.PythonRDD.compute(PythonRDD.scala:65)
      at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:373)
      at org.apache.spark.rdd.RDD.iterator(RDD.scala:337)
      at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)
      at org.apache.spark.scheduler.Task.run(Task.scala:131)
      at org.apache.spark.executor.Executor$TaskRunner.$anonfun$run$3(Executor.scala:506)
      at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1462)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:509)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      ... 1 more
  Caused by: java.net.SocketTimeoutException: Accept timed out
      at java.net.DualStackPlainSocketImpl.waitForNewConnection(Native Method)
      at java.net.DualStackPlainSocketImpl.socketAccept(DualStackPlainSocketImpl.java:131)
      at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:535)
      at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:189)
      at java.net.ServerSocket.implAccept(ServerSocket.java:545)
      at java.net.ServerSocket.accept(ServerSocket.java:513)
      at org.apache.spark.api.python.PythonWorkerFactory.createSimpleWorker(PythonWorkerFactory.scala:175)
      ... 14 more
  
  [Stage 0:&gt;                                                          (0 + 7) / 8]
  Process finished with exit code 1
  </code></pre>
  <p>What is the problem?</p>