There's a great deal of ways to deal with writers block. I'm going to list my two favourites.
You can approach it holistically, or in a more pragmatic and technical manner. The holistic way involves ensuring that you are in such a state that you are feeling present, free and able to express yourself. It is this manner in which you view yourself as a vessel through which inspiration should naturally flow. In order to achieve this state, I suggest that you meditate intensively until you are capable of making (or channelling) the art that you wish to make. I know, meditating is a very unsatisfying shit-fight for quite a while, but ultimately you asked a question and I gave an answer. An answer that I know for a fucking fact works, beyond any shadow of doubt. Yes it involves sitting down in pain (the mental pain of not having a distraction for your animalistic brain to focus on) for hours on end, but if you're not willing to do this, then you don't want the art enough. Simple. Trust me to God, that if you meditate long enough, you will achieve the state that you need. Try a Vipassana course, they are fucking amazing and by donation.
On the more pragmatic and immediately easy side of things, you have the bulldozer method, which involves ignoring the fact that you are not emotionally able to write (which might suggest that you don't actually have anything to say in the first place) and just goes ahead and writes.
In the words of Dmitri Shostakovich-
“I'll admit that writing doesn't always come, but I'm totally against walking around looking at the sky when you're experiencing a block, waiting for inspiration to strike you. Tchaikovsky and Rimsky-Korsakov didn't like each other and agreed on very few things, but they were of one opinion on this: you had to write constantly. If you can't write a major work, write minor trifles. If you can't write at all, orchestrate something.”
So if you have zero inspiration, and thus you do one of two things.
1- You learn specific techniques. For piano, I strengthen my fingers. For music production, I learn how to model synthesizers and copy famous sounds.
2- You remake great works. I honestly don't ever expect to write any 'great' music without first having learnt how to play that of previous masters. When I have no inspiration to create my own music, I sit down and remake a Madonna song or a Kanye song in Ableton. Eventually you get used to making fucking masterpieces and it's not so hard to make your own. Yes it's formulaic, but the whole point of this post is that you probably need to find a good balance between skill and inspiration. Without either, you will not have a complete work.
Peace and love xoxo