Pair programming is good advice - but then, I have a sneaking suspicion that the majority of what you find in Agile programming methodologies is pretty much designed at overcoming the problem that the OP describes.
I found that morning meetings with the other devs on the project, where we are all publicly assigned stories to complete in the day also helps - you don't want the rest of the team feeling like you're slacking off, so you push on through the distractions. But of course, you need the whole team to be on board, and indeed, you need a team!
As I often work alone, the Agile methodology that helps me the most is TDD. It helps me keep focused on what I need to do next. Conceptually it's similar to a TODO list, as suggested in other posts, but it has the advantage that you can't allow the tool itself to be a distraction (I've tried TODO lists, and I end up playing more with the list than with the work). With TDD, either you're writing tests, or you're writing the product code, but either way you are creating an artifact that is useful to the project.
As others said above I'd also suggest you try out pair programming (with a friend of yours). I find myself more relaxed when I'm with someone I can talk to, make jokes or just bitch about the things not working. When I feel stressed I change place with my friend and he continues with the code while I calm down. Also he might see mistakes you don't and helps you fix them right away avoiding the stress.
Another good strategy is to break everything down to small tasks. Tasks you can do in 30 minutes or less. Watching the list getting shorter makes you feel like you're doing something. I think this is part of the agile approach.
I found that morning meetings with the other devs on the project, where we are all publicly assigned stories to complete in the day also helps - you don't want the rest of the team feeling like you're slacking off, so you push on through the distractions. But of course, you need the whole team to be on board, and indeed, you need a team!
As I often work alone, the Agile methodology that helps me the most is TDD. It helps me keep focused on what I need to do next. Conceptually it's similar to a TODO list, as suggested in other posts, but it has the advantage that you can't allow the tool itself to be a distraction (I've tried TODO lists, and I end up playing more with the list than with the work). With TDD, either you're writing tests, or you're writing the product code, but either way you are creating an artifact that is useful to the project.