> For the complete documentation index, see [llms.txt](https://zjffdu.gitbook.io/spark-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zjffdu.gitbook.io/spark-notes/chapter3.md).

# PySpark

Steps:

* bin/pyspark call org.apache.spark.launcher.Main which would build the command to launch python. And also set the shell.py as the startup script of pyspark to start the spark.&#x20;
* context.py will call java\_gateway.py to launch spark by invoking bin/spark-submit.&#x20;
* spark-submit will launch JavaGatewayServer
* Python side create SparkConf and SparkContext through the gateway

bin/pyspark.sh

```
export PYTHONSTARTUP="${SPARK_HOME}/python/pyspark/shell.py"
```
