Edinburgh Airport (EDI) is the closest airport to Edinburgh city centre.
Glasgow Prestwick Airport (PIK) is ~34 miles (55 km) southwest of Edinburgh—over 4x farther. It primarily serves low-cost carriers and cargo. It is closer to Glasgow (32 mi) than to Edinburgh.
Always fly into EDI for Edinburgh; PIK is an alternative only for specific cheap fares or if visiting Ayrshire/Glasgow.