Bobby Shmurda's desperate attempt to get out of his plea deal fell on deaf ears ... as a judge sentenced him to 7 years in prison for gun possession charges.
The rapper was in court Wednesday and in a last-ditch effort ... told the judge he was forced to take the plea, and tried to withdraw it. He even turned to his lawyer in open court and said he wanted to fire him.
Judge wasn't having it, and stuck with the plea deal Bobby had agreed to last month, which he says he took to help his friend ... days before he was to stand trial.
Bobby's already been behind bars for 21 months, so at least he'll get credit for that.