According to an immigration lawyer we consulted, he said that you cannot obtain a study permit while living in Canada on a visitor visa. You actually have to leave Canada and apply for a Study Permit from outside Canada. I wanted to confirm if there is any way a TRV visa holder who is living in Canada can successfully obtain a study permit without having to leave the country?
The lawyer isn't quite right.
You can apply for the study permit while you are in Canada on a TRV, however the study permit application cannot be submitted as a "within Canada" application. You must apply through your home country's visa office or if you are applying online, you must expect that your study permit will be treated as one that is processed outside of Canada. This means you must be prepared to send your passport out of Canada to get the visa stamp if approved, which can be complicated in some cases. Generally speaking, study permits have a lower rate of approval if you apply while you are on a TRV in Canada. But that may not be the case for you depending on the details of your situation in Canada, level of education you are pursuing in Canada, etc.
There are some exceptions to the "within Canada" rules (e.g. minors). We would need to know the specifics of your situation to comment on whether you fall under one of those.