Jupyter cell code error but not in terminal


I am currently testing making a LED light blink with my Raspberry Pi.

When I open up a terminal in Jupyter Lab on a chrome browser on a PC works great, I can execute some code that makes the light blink.

When I try to make a notebook (ipynb file) and just put the same code into a single cell and run it, I get an error.

(pictures are attatched with errors)

It is an error about not having RPI.GPIO but it runs just fine if I just sudo python filename.py in the terminal.

So what is differnet about running code in a cell in Jupyter ipynb notebook file than just running a .py file in a terminal?

(pictures are attatched with errors)

ModuleNotFoundError Traceback (most recent call last)
----> 1 import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
3 from time import sleep # Import the sleep function from the time module
5 GPIO.setwarnings(False) # Ignore warning for now

ModuleNotFoundError: No module named ‘RPi’

This works great, has the exact same code in the cell in the ipynb file

It was for a Jetson Nano Board, so the Jetson GPIO library worked instead.

import Jetson.GPIO as GPIO