Setting up Jupyter Notebook on Visual Studio Code for Data Analytics
This tutorial gives quick and easy steps of setting up Jupyter notebook and other useful data analytics python packages. While some folks might prefer to do this using Anaconda, I would be using Visual Studio Code. The Visual Studio Code supports many programming languages including python. Additional benefits include its ease of use and code debugging features as well as it allows opening of multiple terminal windows to run different code tasks for the frontend and backend, respectively.
1. Download and install the Visual Studio Notebook. The notebook should automatically detect your operating system.
2. It is generally recommended to create a Virtualenv, a tool that provides an isolated environment for your python installation directories. This is done on the terminal window using pip:
pip install virtualenv
In addition, it is good practice to check a python library documentation for useful information on the latest release. Moreover, the documentation provides detailed steps on creating the virtual directory and how to activate/deactivate your virtual environment.
Once this is done, you are ready to install jupyter notebook with just the data analytics python libraries you need. In this case, we considered the numpy, jupyter, pandas and pyspark libraries.
3. Create a project directory with the python __init__.py file to make Python treat it as containing packages. Add a requirement.txt file with the python libraries:
Next, pip install the requirements on the Visual Studio terminal window:
pip install -r requirements.txt
It is assumed that we are using python2.7. For python3 users, replace pip with pip3.
4. Finally, you are ready to (kick) start your jupyter notebook. This command is performed in the visual studio terminal window, which by defaults points to your working directory.
jupyter notebook
Running the jupyter notebook command should within seconds trigger a browser session with the notebook. Kindly note that this would open only if you have successfully activated your virtualenv as described in Step 2. Now, all you need is to import your installed python data analytics libraries within your notebook and you are all good to go with ‘happy data analytics’.
About the author:
Taiwo O. Adetiloye, PhD. is an Information Systems Engineer with over 10 years of research and development experience. He is very interested in software development with large-scale data processing and analytics using AI and ML frameworks like Spark, Keras, Tensorflow, Pytorch, MxNet etc. His favourite programming languages are Golang, Python, Java and Scala.
He is constantly developing himself as an information technologist working and acquiring new skill sets to help him in his career growth. He is a highly motivated individual, good communicator and a great team player with a passion for creativity and a drive for excellence.
Other articles by the author: