Usually I try to take out scouts by hiding around a corner and guessing when they'll be rounding it: if the guess is right, you should land your kukri right on their face. Rinse, repeat... But scouts are quite good at killing snipers, so don't be surprised if you get killed by them frequently. Note that if for some reason they create distance between you and them, the sniper rifle is good with long range

Pyros are easy if you see them coming. Headshot, pull out smg or kukri. Remember that getting within range of a pyro isn't instant death. I kukri low-health pyros all the time. Although, the smg is most useful for keeping your distance.
Spies are gonna get you sometimes. Best counter is to snipe around a sentry... I get stupid spies backstabbing me instead of trying to sap a sentry, sometimes, but generally, you're safe like this. Otherwise, really, you should keep moving, not stay in one spot too long, but don't actively look for spies. You can't let them ruin your game.
Lastly: Learn how to noscope.