Pyspark on Intellij with packages & auto-complete

Image for post
Image for post

Most of the pyspark folks are used to working with notebooks mostly jupyter and sometimes zeppelin. Notebooks provides a wonderful way to execute code line by line and get evaluated result at every paragraph. As developers we just have one problem with it, the notebook is far from a full blown IDE.


  1. IDE gives a wonderful way to get inside the code of libraries and understand them.
  2. It provides you with wonderful typeahead ( autocomplete)
  3. Lets you run things in debug mode

Lets get rolling

  1. Prerequisites:
  • Install python 3.6
brew install
python --version

2. Install python plugin for intellij and restart

  • Go to Preferences -> Plugins -> Market Place -> Python -> Install
Image for post
Image for post

Lets get to actual code, we will setup spark deep learning project with Keras :

3. Create new project with Intellij, choose Python style, give it a name

Image for post
Image for post

4. Open Project Structure and click on New Project SDK , choose Virtual Environment, Select a location within your project as venv and base interpreter from previously installed python

Image for post
Image for post

5. Lets add requirements.txt from so that we have all the python requirements in. We need to add pyspark and ipython

6. Create a new file and copy over the contents from notebook, it would show lot of red lines indicating non-linked package.

7. We need to add the deep-learning library, but then we need deep-learning jar as well as transitive dependencies, for this we create pom.xml with deep-learning library. Using Maven installer we copy all the dependencies to the jars folder.

8. Now we need to add these jars to the IDE environment. Goto Project Structure , Libraries , then add Java lib and select jars folder. This will make your IDE understand the python code inside the jars

9. We still need to add jars to pyspark startup. Open Run and then Edit Configuration . Goto Templates, Python and add following Environment Variables :

  • PYSPARK_SUBMIT_ARGS —-driver-memory 2g --jars jars/*.jar pyspark-shell
  • no_proxy *

10. Add the flower_photo and sample_photos as per tutorial

11. Finally right-click and run your SparkDL


Image for post
Image for post

All of the source code published at :

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store