early in the 18th century, the city was threatened or invaded by several mostly French pirates and buccaneers, such as Jean-François Duclerc and René Duguay-Trouin. In the late 17th century, still during the Sugar Era, the Bandeirantes discovered gold and diamonds in the neighboring captaincy of Minas Gerais, thus Rio de Janeiro became a much more practical port for exporting wealth (gold, precious stones, besides the sugar) than Salvador, Bahia, much farther northeast. On 27 January 1763, the colonial administration in Portuguese America was moved from Salvador to Rio de Janeiro. The city remained primarily a colonial capital until 1808, when the Portuguese royal family and most of the associated Lisbon nobles, fleeing from Napoleon's invasion of Portugal, moved to Rio de Janeiro. Portuguese court and imperial capital The kingdom's capital was transferred to the city, which, thus, became the only European capital outside of Europe. As there was no physical space or urban structure to accommodate hundreds of noblemen who arrived suddenly, many inhabitants were simply evicted from their homes. In the first decade, several educational establishments were created, such as the Military Academy, the Royal School of Sciences, Arts and Crafts and the Imperial Academy of Fine Arts, as well as the National Library of Brazil – with the largest collection in Latin America – and The Botanical Garden. The first printed newspaper in Brazil, the Gazeta do Rio de Janeiro, came into circulation during this period. When Brazil was elevated to Kingdom in 1815, it became the capital of the United Kingdom of Portugal, Brazil and the Algarves until the return of the Portuguese Royal Family to Lisbon in 1821, but remained as capital of the Kingdom of Brazil. From the colonial period until the first independent era, Rio de Janeiro was a city of slaves. There was a large influx of African slaves to Rio de Janeiro: in 1819, there were 145,000 slaves in the captaincy. In 1840, the number of slaves reached 220,000 people. Between 1811 and 1831, 500,000 to a million slaves arrived in Rio de Janeiro through Valongo Wharf, which is now a World Heritage Site. The Port of Rio de Janeiro was the largest port of slaves in America. When Prince Pedro proclaimed the independence of Brazil in 1822, he decided to keep Rio de Janeiro as the capital of his new empire while the place was enriched with sugar cane agriculture