Most probably you will need a visa to enter Tanzania when you are travelling from Europe or the USA. Countries which are not required to apply for a visa can be found here.
How do I apply for a visa to Tanzania?
Although it is possible to buy a tourist visa upon arrival at the airports of Dar es Salaam, Kilimanjaro and Zanzibar, we recommend that you apply for a visa in your home country prior to your trip. You can do this online at: https://eservices.immigration.go.tz/visa/
Don't leave it last minute, latest two weeks before arrival in Tanzania so you are sure you give them enough time to process your online application. The application will take 20-40 minutes of your time and it will make it easier if you have the below documents ready:
A copy of your passport (scanned on your computer, low resolution)
Your e-ticket (as a document on your computer)
Passport size picture (scanned on your computer, in low resolution)
When you are too close to your departure date and therefor too late for the online procedure you can arrange your visa for Tanzania upon arrival at the airport. You have to pay for the visa in USD dollars and they only take cash payments.