In my program with a virtualenv and using pyserial, I can run this code fine:
import serial with serial.Serial() as ser: ser.baudrate = 38400 ser.port