Raspberry pi cam V2 preview not showing

Hi everyone! I hope you are doing well. I am Simon from the USA and I went to some meetings when I was in Canberra. While using the raspberry pi 4, I connected the camera module and started to use it. The raspistill function outputted a picture and I was able to view it. I should have gotten a preview but I did not. This python code should also make a preview window appear but it didn’t:

from picamera import PiCamera
from time import sleep

camera = PiCamera()

camera.start_preview()
sleep(5)
camera.stop_preview()

I have used some of the raspistill flags like -p and -f for preview and fullscreen preview, but no windows have appeared. Any advice is welcome. Thank you