There are roughly four methods for controlling your writing (or studying) environment:
1. Place
2. Location within a Place
3. People
4. Time
Place. I write fairly well in a coffee shop with a bit of background noise/sound. Sitting in my bedroom is often too distracting. Many libraries today are too noisy. So, I prefer the coffee shop.
Location. Sometimes facing away from other people or away from the window is better for concentration. Other times, I work better with a bit of visual distraction. You have to experiment.
People. Other people can distract you and you will not get anything done. I like to work around other professionals (eg. Lawyer, writers) who are also busy. Or quietly studying students.
Time. Morning and evenings work best for me.