How to supervise a bad PhD student
Since I have been that student at the beginning of my PhD, I think I can give you some perspective. I was very motivated when I started, but I didn't know anything about research, so I lost my motivation when I had to be on my own.
I tried the same approach as your student with my PhD adviser, and he told me he's not going to do my work or homework because I have to be able to do everything myself. Obviously, everything I did as a PhD student, I can still do now, so it worked.
But, you have to establish your boundaries. You have to set some discipline, and the first thing is to reduce the interaction with your student. Set a meeting, once a week. One day before the meeting, your student should put in writing, briefly, what progress he made, and what problems he encountered -- that should be discussed in the first half of the meeting. The rest of the meeting will be you telling him what needs to be done next. You should not talk with or help your student outside these meetings, and you should ignore those abusive "help now!!!" emails he's writing you.
If your student just wants to do his job quick, as you describe, you have to realize his output won't be something you can rely on. You need to give him two types of assignments. Some imply things he already does well, so he doesn't lose completely his courage, and the others imply him learning new stuff. The latter have to be easier. You do not help him with them beyond suggesting papers or books to look things up. In case of programming, suggest SE for him to look for help, and give him some examples to get him started and nothing else. Under no conditions you should do his work.
There are things you should demand from your student. If he has to present data to you, the data should be in the format your group is already using, if there is code that he needs to write, it should be documented, and he has to present tests that it's working. If you assigned him to read a certain paper, you have to make sure he read it. If you told him to search for literature, he needs to be able to discuss what he found and how is that relevant for the project and so on.
Since you are a postdoc, you probably can't enforce things properly. If you were his adviser, you could tell him to follow your discipline, or find another adviser. As a postdoc, you could go to the boss, tell them about what's going on and that the student consumes too much of your time. Tell them you are thinking of setting a discipline and ask them to back you up, especially since you are doing their job. Anyway, whatever you do, once you set your new set of rules, don't let him cross them, or break them yourself.
Edit - in response to @CaffeineAddiction comment claiming that, as an adviser you need to introduce the student to the basics.
The job of the adviser is not to introduce you to the foundations of whatever field. Part of that job is to teach the student how to introduce themselves to the basics. In other words, you don't teach the man to fish, you teach the man to teach himself how to fish. The basics should have been covered in classes. If they were not, you do have to make a compromise, and intervene when the student seems to have a block and doesn't make progress. But, you do that simply because you don't want to lose the student.
That's what I do. If my student has no background, I give him an easy test case, I suggest them a class to take, I recommend a book, or two, and give them one of the not so complex code that works. The code is a model, and might contain a few layers of complexity. My job is to make the student aware of this, and guide them to search for the knowledge they need to improve the code, or write their own.
I took the code as an example, since that was the original question. But, when you start research in my field, you don't get a code. You get a paper with a bunch of formulas. To understand those formulas, you need a few years of reading textbooks and other research papers. It's very easy to get lost in the process, in other words, spending 6 months on trying to understand something completely irrelevant. The adviser's job is to offer limited guidance to understanding that paper, help you recognize your blocks and address them. The heavy lifting is still yours.
As far as I understand, there are only two valuable skills that an adviser is responsible to teach a PhD student. The first is to teach the student how to learn on their own a completely new subject. The second skill an adviser must teach is how to do research. Many advisers skip the first skill because of many reasons, but mostly because of the lack of time. Then they complain about students with technician mentality. But, learning that first skill, also teaches you the right attitude towards the unknown, which is essential in research.
I am currently on my second PhD since I dropped out of the first one. I was the "nightmare student," and so I'd like to give you my perspective. This may not be relevant, but I started out as highly enthusiastic and motivated but got disillusioned as the level was much higher than I anticipated. Like your student I was moving into a physics field with a different background (biology) and had no real coding experience.
I experienced something that can only be described as "turbulence." I became so paranoid and insecure that I couldn't do anything by myself. My supervisor and project postdoc would send me some code, or a task they needed to do, and I would freeze. I'm an intelligent person but my brain couldn't focus. I'd read Stack Exchange and be unable to implement the solutions. If a solution varied even slightly, I wouldn't be able to implement it.
There was some underlying psychological problem. Insecurity, anxiety, stress -- whatever it was, I was a nightmare to be around. I never became independent and the more boundaries people tried to put up with me, the worse I got.
When I eventually quit, it was the greatest relief of my life. My postdoc hated me and was openly criticising me for my lack of independence. For some people that works, but for me it made me freeze even more. I'd panic, I was desperate for validation, and just couldn't concentrate.
Objectively I agree with every other comment here: set boundaries, he needs to become independent, don't exhaust yourself. But for me, those responses made me worse. Deep down I didn't think I was capable but couldn't admit it to myself so was stressed out and needy. Paradoxically, what would have helped me most would have been to be reassured that I could do it as a person. E.g., that I was fundamentally worthy and deserving of my place in the department, and that my weaknesses were not inherent parts of me, but skills that could be overcome.
Sounds so stupid!!! I'm sure many people will feel cynical about that, with good reason. But if I'd had that space to feel emotionally secure I would have felt more grounded, safe and able to solve my problems. In the end, feeling valued and secure would have saved my PhD when being criticised only made me more insecure, but that's just my experience. I know this must sound ridiculous. It was just my situation.
The only positive for me is that I now know everything to avoid on my second PhD. But it would have been preferable to get here without wasting 3 years' of public funding and annoying a lot of people.
I get the impression the student wants to do a technician's, rather than a scientist's, job but still get a PhD out of it.
From what you've described, this seems like a very accurate assessment, and it's the crux of the matter. You need to get this message across to your student. Magicsowon's answer does a great job covering the practical aspects of how to (attempt to) get the student out of their bad habits. I think also explaining the situation to them very clearly is an important component. You have already brought up some concerns with him, but perhaps there is room to be more blunt/direct. You need to get the following points across:
- The difference between a technician and a researcher, as alluded to in the quote above. A PhD is not awarded just for putting in a certain number of hours. It is a certification that you have the ability/potential to be an independent researcher. Merely working through a set of tasks with one's hand held throughout does not demonstrate that ability.
- Someone who has been showing no initiative and requires that much help is going to really struggle in their thesis defence.
- Difficulties such as "tasks are too complicated..., the professor does not help enough, the project is not well organized" are ones that will crop up throughout a scientific career. If the student cannot find strategies to cope with them, they cannot be a successful scientist.