They say that practice makes perfect. This is true but in that you have to know how to practice perfectly. Good practice is making sure that you are learning, developing, applying and integrating what you learn in the right way. Part of this is learning in the right environment free from distraction. So, if you are trying to learn a new song or practice your improvisation it requires your full attention.
However there are situations where you need to practice things so that they become second nature and you can do them well enough to the extent that you can focus on something else whilst you do this particular thing. Think about technique. Having great technique is not the be all and end all of musical skills but it does help. If you are trying to learn a song then it helps to have good physical ability. If you are writing or improvising then it helps to have a good enough of a technical grasp of the guitar so that you can focus on what to play rather than how to play it.
I was fortunate enough to discover this a few years ago when I developed glandular fever. With no energy whatsoever I resigned myself to sitting on the couch and watching films all week whilst I recovered. Whilst I sat I had my guitar with me and as film after film went by I practiced. There were some particular techniques that I was working on, mostly focusing on well played rock cliches like this...
The problem with practicing stuff like this normally is that the mind can wander. If you are doing something repetitive like playing this lick over and over again whilst you get your technique right it can get pretty dull and if you lack the focus then you will probably not be making the best use of your practice time. In addition by practicing on your own you can develop a 'practice mindset approach' to playing, where everything sounds great when you are practiced and focused but when the distraction of other elements comes into play (other musicians for example) then certain things can fall apart.
For me what worked a treat was practicing with the TV on. I would play this lick enough so that I could play in time with a metronome at a reasonable speed. Then I would play it to death as I watched the Lord Of The Rings trilogy or something. With the distraction of TV I was able to play again and again building up strength and stamina to the point that playing the lick over and over again was effortless. From time to time I would check my technique to make sure that I was still doing it right, make any corrections and then back to the TV. Once I'd felt happy that I'd mastered this lick and was comfortable doing it, I would practice a similar one, or practice two of them side by side, or practice the licks in different parts of the neck. By the time I had recovered I'd played a lot of guitar and stuff like this felt much easier as I was clocking up 7-8 hours of practice a day.
Please don't read into this thinking 'if I practice with the TV on I'll get much better quicker'. This only works on the repetitive things you need to work on and things that you already can do that you need to do again and again for them to become second nature. The best way to utilise general practice is to play in a distraction free environment where you can focus on what you need to. However for practicing some things a change of environment can make all the difference. Give it a try.