How to ask for a recommendation letter if no professor knows me in person?
Asking for a recommendation letter from a person who does not know you makes sense neither for you nor for a potential referee. The purpose of a reference letter is to let others know about your work habits, your motivation, your skills etc. A person who does not know you can not judge any of these things, thus even if you can convince a professor to write a letter about you it might not necessarily have a benefit for an application when it simply states that you have attended some courses. 
You could try to contact a professor in a field you feel motivation for and whose work you are interested in and ask about potential student projects, irrespective of courses or credits. This can:


Help get to know a professor personally
Help you figure out if you enjoy working in an academic environment
Get you a personal recommendation letter