In a Python 2 notebook, prefix the above with the following code to ensure the local workers use Python 2 as well.
```python
importos
os.environ['PYSPARK_PYTHON']='python2'
# include pyspark cells from above here ...
```
## Connecting to a Spark Cluster on Mesos
## Connecting to a Spark Cluster on Mesos
This configuration allows your compute cluster to scale with your data.
This configuration allows your compute cluster to scale with your data.
...
@@ -58,7 +49,7 @@ This configuration allows your compute cluster to scale with your data.
...
@@ -58,7 +49,7 @@ This configuration allows your compute cluster to scale with your data.
* NOTE: When using `--net=host`, you must also use the flags `--pid=host -e TINI_SUBREAPER=true`. See https://github.com/jupyter/docker-stacks/issues/64 for details.
* NOTE: When using `--net=host`, you must also use the flags `--pid=host -e TINI_SUBREAPER=true`. See https://github.com/jupyter/docker-stacks/issues/64 for details.
4. Open a Python 2 or 3 notebook.
4. Open a Python 2 or 3 notebook.
5. Create a `SparkConf` instance in a new notebook pointing to your Mesos master node (or Zookeeper instance) and Spark binary package location.
5. Create a `SparkConf` instance in a new notebook pointing to your Mesos master node (or Zookeeper instance) and Spark binary package location.
6. Create a `SparkContext` using this configuration.
6. Create a `SparkContext` using this configuration.
For example, the first few cells in a Python 3 notebook might read:
For example, the first few cells in a Python 3 notebook might read:
...
@@ -73,7 +64,7 @@ conf = pyspark.SparkConf()
...
@@ -73,7 +64,7 @@ conf = pyspark.SparkConf()
# point to mesos master or zookeeper entry (e.g., zk://10.10.10.10:2181/mesos)
# point to mesos master or zookeeper entry (e.g., zk://10.10.10.10:2181/mesos)
conf.setMaster("mesos://10.10.10.10:5050")
conf.setMaster("mesos://10.10.10.10:5050")
# point to spark binary package in HDFS or on local filesystem on all slave
# point to spark binary package in HDFS or on local filesystem on all slave