To achieve slow dimming or brightening of your LED you will require (as others have posted before) PWM.
Introduction to PWM
There are primarily two types of modulation software and hardware. There exist several libraries which can achieve a software enabled modulation whose performance lies in between software and hardware. You could read up more about the different types of modulation on this answer here.
Solution to your query (without having to buy or install anything)
The finer your application the more advanced the PWM you need to use, for your purpose (LEDs) the precision required is not too great and thus it can be achieved by simple GPIO modulation.
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) # choose BCM or BOARD numbering schemes. I use BCM
GPIO.setup(26, GPIO.OUT)# set GPIO 26 as output for led
led= GPIO.PWM(26,100) # create object led for PWM on port 25 at 100 Hertz
led.start(0) # start led on 0 percent duty cycle (off)
pause_time = 0.02 # you can change this to slow down/speed up
try:
while True:
for i in range(0,101): # 101 because it stops when it finishes 100
led.ChangeDutyCycle(i)
sleep(pause_time)
for i in range(100,-1,-1): # from 100 to zero in steps of -1
led.ChangeDutyCycle(i)
sleep(pause_time)
except KeyboardInterrupt:
led.stop() # stop the led PWM output
GPIO.cleanup() # clean up GPIO on CTRL+C exit
This code will increase and then decrease the brightness. You can, of course, edit the code to your needs.