I have already have Ipython notebook and Spark distribution 1.6 installed and configured in my PC (OS: Ubuntu). What I need to do is to (1) set environment variables and (2) configure Ipython profile.
For (1). Open terminal, and type two lines:
$ export SPARK_HOME="/home/xywang/spark-1.6.1-bin-hadoop2.6" $ export PYSPARK_SUBMIT_ARGS="--master local[2]"
The 1st line tells your system where is your Spark home directory (change it accordingly to your distribution), and the 2nd line defines that you will run a single mode.
For (2). In terminal, type:
$ ipython profile create pyspark
After this command, a directory " ~/.ipython/profile_pyspark/" will be created. Go to its subdirectory "startup" and created a file named "00-pyspark-setup.py", and fill in the following content:
As you might use different Spark distribution as me, you might need to change the name of "py4j-0.9-src.zip" and "Spark 1.X".
After (1) and (2), you can start your Ipython notebook with pyspark profile, simply type this command
$ ipython notebook --profile=pyspark
If everything is alright, you can run SparkContext in Ipython notebook. For example, you can try to load a textFile like this:
I feel using Ipython notebook is better than typing commands through terminal, it is easier for me to track my code and to copy/paste of course.
Credit to [1] and [2].
-------- Update for Spark-2.2.0 + Jupyter Notebook --------
An easier way to link pyspark with jupyter notebook is to add values to
PYSPARK_DRIVER_PYTHON and PYSPARK_DRIVER_PYTHON_OPTS in ~/.profile such that:
$ echo "export PYSPARK_DRIVER_PYTHON=jupyter" >> .profile $ echo "export PYSPARK_DRIVER_PYTHON_OPTS='notebook' pyspark" >> .profile $ source .profile
Reference: [3]
I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
ReplyDeleteAmazon Web Services Training in Chennai
Best Java Training Institute Chennai
Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
ReplyDeleteAngularjs Training in Chennai
Angular 2 Training in Chennai
Angular 4 Training in Chennai
angularjs training center in chennai
Angularjs Training Chennai
Angularjs courses in Chennai
Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
ReplyDeleteGood discussion.
Salesforce Administrator 201 Training in Chennai
Salesforce Administrator 211 Training in Chennai
Salesforce Developer 401 Training in Chennai
Cloud computing Training in Chennai
Cloud computing courses in Chennai
Cloud Training in Chennai
This is the information that have been looking for. Great insights & you have explained it really well. Thank you & looking forward for more of such valuable updates.
ReplyDeletejava training in chennai
java training in velachery
aws training in chennai
aws training in velachery
python training in chennai
python training in velachery
selenium training in chennai
selenium training in velachery
I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.keep share!!
ReplyDeleteoracle training in chennai
oracle training in annanagar
oracle dba training in chennai
oracle dba training in annanagar
ccna training in chennai
ccna training in annanagar
seo training in chennai
seo training in annanagar
Great Article. Thank you for sharing! Really an awesome post for every one.
ReplyDeletehardware and networking training in chennai
hardware and networking training in tambaram
xamarin training in chennai
xamarin training in tambaram
ios training in chennai
ios training in tambaram
iot training in chennai
iot training in tambaram
Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
ReplyDeleteGood discussion.
data science training in chennai
data science training in omr
android training in chennai
android training in omr
devops training in chennai
devops training in omr
artificial intelligence training in chennai
artificial intelligence training in omr