What's the difference between %python and %pyspark in a Zeppelin notebook (screenshot below)?
- I can run the same python commands with both cases (like
print('hello'))I can use the the same PySpark API in both casesi.e.from pyspark.sql import SparkSession, andspark.read.csv- EDIT 10/31/2019 This is no longer true; in a
%pythoninterpreter I get the messageNo module named pyspark. - I guess I can install the missing module using
pip install pyspark, but I don't know how to install onto a Zeppelin resource.
EDIT 10/31/2019 I must use a
pythoninterpreter, vs apython3interpreter, else I get an error like:Exception: Python in worker has different version 2.7 than that in driver 3.6, PySpark cannot run with different minor versions.Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set.- Also, I guess this module was installed on Zeppelin when I used it earlier this year.
I can even toggle back and forth; using them both simultaneously?i.e. first paragraph uses%python, next paragraph uses%pyspark- Nevermind; each language cannot see the variables defined by the other language...
- They just have the same (Python) API, i.e. each can create their own dataframe
spark.createDataFrame([...])
- I see from the screenshot below that those languages use different
interpeters:
%pythonlanguage ->pythoninterpreter%pysparklanguage ->sparkinterpreter
...But what's the difference between using those interpreters, if my API / code is all the same? Is either of them faster/newer/better? Why use one over the other?

%pysparkcreates a spark context automatically with the defined parameters (loading spark packages, settings...) for the spark-interpreter. In%pythonyou can create a spark context by your own but it is not down automatically. - cronoik%pysparkwill implicitly define asparkvariable / session for me, whereas with%pythonI must create thesparkvariable / session myself, manually? I see that difference saves me some work when using%pyspark, although I wonder what settings it uses to create the session (i.e.appName('...')) Thank you! If you post this as answer I will accept. - The Red Pea