Buying tickets from an automated vending machine located in any metro station. NOTE that if you pay with a credit card, the machine requires a PIN.
You’re better off choosing the T-10 travelcard (a single physical ticket reusable for 10 rides). If you are traveling with others, you can even share a T-10 ticket. The first person uses their ticket and passes it back to the next person. Make sure you buy the T-10 travelcard for ZONE 1, which cover the whole city and surrounding towns. It is valid to/from the airport at El Prat via bus #46 (from Plaça Espanya) or train (from either Sants or Passeig de Gràcia stations). The T-10 is NOT valid for the Aerobus.
Video: © InterestingClass