Installing and Running Jupyter Notebook: Complete Guide

To run the visualization code examples from our blog post, you'll need to set up Jupyter Notebook on your computer. Here's a step-by-step guide:

1. Install Python (If Not Already Installed)

Jupyter requires Python 3.6 or higher. Download from:

Verify installation:

bash
python --version
# or
python3 --version

2. Install Jupyter Notebook

bash
# Install using pip (Python package manager)
pip install notebook

# For Mac/Linux users, you might need:
pip3 install notebook

3. Launch Jupyter Notebook

bash
# Start the notebook server
jupyter notebook

This will automatically open your web browser to http://localhost:8888


Running the Visualization Code

  1. Create a new notebook:

    • Click "New" > "Python 3" in the top right

  2. Install required libraries (first cell):

    python
    !pip install matplotlib seaborn pandas numpy
  3. Import libraries (new cell):

    python
    import matplotlib.pyplot as plt
    import seaborn as sns
    import pandas as pd
    import numpy as np
  4. Run visualization code (new cells):

    python
    # Example: Line plot
    months = ['Jan', 'Feb', 'Mar', 'Apr']
    revenue = [12000, 18000, 15000, 22000]
    
    plt.figure(figsize=(10, 5))
    plt.plot(months, revenue, marker='o', linestyle='--', color='#2c7bb6')
    plt.title('Monthly Revenue Growth', fontsize=14)
    plt.show()
  5. Execute code:

    • Press Shift + Enter to run the current cell

    • Use Ctrl + Enter to run and stay in the cell


Pro Tips for Jupyter

  1. Keyboard Shortcuts:

    • a: Insert cell above

    • b: Insert cell below

    • dd: Delete cell

    • m: Convert to Markdown

    • Tab: Auto-complete

  2. Save Plots to Files:

    python
    plt.savefig('sales_trend.png', dpi=300, bbox_inches='tight')
  3. View Available Functions:

    python
    # After importing, press Tab
    sns.<Tab>
  4. Magic Commands:

    python
    %matplotlib inline  # Show plots in notebook
    %load_ext autoreload # Auto-reload modules
    %autoreload 2

Alternative Installation Methods

Option 1: Install with Anaconda (Recommended for Beginners)

  1. Download Anaconda

  2. Follow installer instructions

  3. Launch Jupyter from Anaconda Navigator

Option 2: Use Google Colab (No Installation)

  1. Go to Google Colab

  2. Create new notebook

  3. Skip installation steps (libraries pre-installed)


Troubleshooting Common Issues

  1. "Command not found: jupyter":

    bash
    python -m pip install --upgrade pip
    python -m pip install jupyter
  2. Plot Not Displaying:
    Add this as first cell:

    python
    %matplotlib inline
  3. Kernel Not Starting:

    bash
    pip install --upgrade ipykernel
  4. Missing Libraries:

    bash
    pip install matplotlib seaborn pandas numpy

Sample Workflow for Our Visualization Blog

python
# Cell 1: Setup
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
sns.set_style('whitegrid')  # Set global style

# Cell 2: Create sample data
data = {'Region': ['North','North','South','South','East','East'],
        'Category': ['Electronics','Clothing','Electronics','Clothing','Electronics','Clothing'],
        'Sales': [120000, 80000, 95000, 75000, 110000, 85000]}
df = pd.DataFrame(data)

# Cell 3: Create visualization
plt.figure(figsize=(10,6))
sns.barplot(x='Region', y='Sales', hue='Category', data=df, palette='viridis')
plt.title('Regional Sales by Product Category', fontsize=16)
plt.ylabel('Sales ($)', fontsize=12)
plt.legend(title='Product Category')
plt.savefig('regional_sales.png', dpi=300)  # Save high-res version
plt.show()

Now you're ready to create professional visualizations! For more advanced techniques, see our tutorial on Interactive Plotting with Plotly.