KevsRobots Learning Platform
22% Percent Complete
By Kevin McAleer, 5 Minutes
To build a custom object detection model, you’ll need a proper development environment. In this lesson, you’ll set up Jupyter Lab, which provides an interactive workspace perfect for machine learning experimentation. You’ll also create an isolated Python environment to keep your project dependencies organized.
Jupyter Lab provides an interactive environment perfect for machine learning work:
Professional ML engineers use Jupyter for prototyping before deploying to production. It’s the industry standard for exploratory data analysis and model development.
A virtual environment keeps your project dependencies separate from your system Python installation. This prevents version conflicts and makes your project portable.
# Create a new virtual environment named 'venv'
python -m venv venv
What this does:
venv containing a fresh Python installationActivate your virtual environment before installing packages:
On macOS/Linux:
source venv/bin/activate
On Windows:
venv\Scripts\activate
You’ll know it worked when:
(venv) at the beginningwhich python shows the path to your venv PythonNow install Jupyter Lab and supporting tools:
pip install jupyterlab ipykernel label-studio
What each package does:
jupyterlab - Interactive development environmentipykernel - Allows Jupyter to run Python codelabel-studio - Tool for annotating images (we’ll use this later)Installation time: About 2-3 minutes depending on your internet speed.
Register your virtual environment as a Jupyter kernel:
python -m ipykernel install --user --name=venv --display-name "Python (venv)"
What this does:
Start Jupyter Lab with this command:
jupyter lab --ip=0.0.0.0 --port=8888 --no-browser
Command options explained:
--ip=0.0.0.0 - Allows access from any network interface (useful for remote access)--port=8888 - Runs on port 8888 (default Jupyter port)--no-browser - Doesn’t auto-open a browser (you’ll open it manually)Expected output:
[I 2024-10-16 10:30:00.000 ServerApp] Jupyter Server is running at:
[I 2024-10-16 10:30:00.000 ServerApp] http://localhost:8888/lab?token=abc123...
Copy the URL with the token and paste it into your browser.
Let’s confirm everything is installed correctly. Create a new notebook in Jupyter Lab and run this code:
# test_setup.py
import sys
import jupyterlab
import ipykernel
print("✓ Python version:", sys.version)
print("✓ Jupyter Lab version:", jupyterlab.__version__)
print("✓ IPyKernel version:", ipykernel.__version__)
print("\nSetup successful! You're ready to go.")
Expected output:
✓ Python version: 3.10.12 (main, Jun 11 2023, 05:26:28)
✓ Jupyter Lab version: 4.0.0
✓ IPyKernel version: 6.25.0
Setup successful! You're ready to go.
print("Hello, AI Camera!") in a cell and press Shift+Enter!pip install matplotlibChallenge: Create a simple plot to verify matplotlib is working:
import matplotlib.pyplot as plt
plt.figure(figsize=(8, 4))
plt.plot([1, 2, 3, 4], [1, 4, 2, 3])
plt.title('Test Plot')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.show()
You should see a line graph appear below the cell!
Problem: “python: command not found”
Solution: Install Python from python.org or use your package manager (brew install python3 on Mac, sudo apt install python3 on Linux)
Why: Python needs to be installed on your system first
Problem: “pip: command not found”
Solution: Try python -m pip instead of pip, or reinstall Python with pip included
Why: pip might not be in your PATH, or wasn’t installed with Python
Problem: Virtual environment won’t activate on Windows
Solution: Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell
Why: Windows security policy blocks script execution by default
Problem: Can’t access Jupyter Lab from browser
Solution: Check firewall settings, or use localhost:8888 instead of 0.0.0.0:8888 in the URL
Why: Firewall may be blocking the port or network configuration issue
Problem: “Kernel dead” or “Kernel error” in Jupyter Solution: Restart the kernel (Kernel → Restart Kernel), or recreate the ipykernel installation Why: Package conflict or incomplete installation
You’ve learned:
Your development environment is now ready! In the next lesson, you’ll learn how to prepare a custom dataset for training your object detection model.
In the next lesson, you’ll learn how to collect and annotate images to create a custom object detection dataset.
You can use the arrows ← → on your keyboard to navigate between lessons.
Comments