To deploy a Python script on a Jetson Nano 2GB and have it start automatically at boot, the most robust and recommended way is to use a systemd service. This method is reliable, works for both headless and GUI environments, and gives you control over dependencies, restarts, and logging.
Here’s a step-by-step guide:
1. Prepare Your Python Script
Suppose your script is called my_script.py and is located at /home/jetson/my_script.py.
Make sure your script is executable and has the correct shebang at the top:
python
#!/usr/bin/env python3
Then:
bash
chmod +x /home/jetson/my_script.py
2. Create a systemd Service File
Create a new service file, e.g., my_script.service:
bash
sudo nano /etc/systemd/system/my_script.service
Add the following content (edit paths and user as needed):