All foreigners that wish to study in Brazil need to apply for a student visa beforehand. The main requirement to get a student visa is that you are enrolled at a Brazilian university that is registered with the Ministry of Education in Brazil.
All Brazilian student visas are called Temporary Visa IV, or VITEM-IV. You can apply for your visa at the nearest General Consulate or Brazilian embassy. For an overview of Brazilian missions abroad, visit: http://www.itamaraty.gov.br/en/brazilian-missions-abroad
Before going to the embassy, you should consult their website to obtain a student visa application, a list of requirements, and to verify the application process and timetable.
After being granted the visa, you will have three months to enter Brazil.
The VITEM-IV are valid for up to one year at a time, depending on the length of the course you are enrolled in, and can be renewed in order for you to finish the course. For interns, the student visa is valid for one year and cannot be renewed.