If the "fun part" of learning or working on a project is analogous to the climbing of a mountain, you have to acknowledge that there are parts of learning and working that have natural plateaus - you wander in them for a long time and you don't seem to be climbing at all. There are only two ways to consistently get through those spots: by habit, or by obligation.

By obligation is the more familiar method for a student: You were told to do your homework and study, now you have to deliver. And then you fear not fulfilling it so you get into a panic at the last minute and scramble to produce the image, if not the reality, of someone who knows what they're doing and learned what they were supposed to learn. Somehow you retain some of that knowledge and so you do become more competent, but you associate the process of getting there with the stressful experience of delivering to a deadline.

Doing it by habit means that there is a part of your time in the day where you do some subset of "important but boring" things, entirely for yourself. Not because somebody told you to. This is the sane way to learn things and also the only one that you can sustain throughout your life.

That is, tomorrow, instead of sitting in your comfort zone at home and watching yet another lecture or skimming yet another blog post, you go out to a coffee shop and you sit there for at least one hour to study "the doing of work." You don't dare get up until you've seen at least a tiny fraction of productivity. Maybe you learned one fact, or you figured out one part of a math problem, or you set up your development environment, or you wrote one important business email. If you accomplish it at the start of the hour, you keep going, you find one more thing to do, and then one more after that, and so on.

This feels horrible in the homework mindset, because the goal there is to minimize effort and maximize output, to procrastinate and then rush to get the grade. Here the goal is akin to going to the gym, to practice putting in effort, to get used to the idea of everyday struggle so that you don't fear it. Here, it does not matter how little your output was, if your effort was good. And if you are frustrated with what you are trying to work on, allow yourself multiple options. You shouldn't do only bicep curls every day, and you shouldn't do the same with intellectual work.

The homework mindset will creep in and say that this free time should be carved up, rebalanced, and associated with deadlines again, in line with whatever goals and values the parents, teachers, or institutions presently uphold, you should be progressing as fast as the course does, but that is not true. You don't know what is efficient, you don't know what is valuable, and you don't know exactly where you're going in the future. You won't progress exactly as fast as any course, you will breeze through some things and be stuck on others. You will have to try to know. Defer to your own motivations in practicing the doing of work, because sitting there dumbfounded by material you cannot bring yourself to engage with is a good way to crush your spirit and make you feel incapable. This is true even if it should lead to failure within your coursework, as that failure, in tandem with knowing that you were actually practicing and learning things each day, will indicate that you were lying to yourself about what you want and why. That is more important than simply maintaining the image of competence.

Try make sure you are actually as healthy as possible. Maybe you are eating or drinking something that makes you unable to focus, or not enough of something else - experiment, try things. Maybe you need to get out so that when you come back, you're excited about what you're doing. There are many things to try. A well-rounded life needs to try as many of them as possible as early as possible.