The young man, who killed his victims out in the street before taking refuge in a house, was later shot dead by police when he left that house and ran towards them in a threatening way, a police source said.
"The police operation is over ... the person was neutralised and is dead," the local prefecture said on Twitter.
BFM TV said the attacker shouted "Allahu Akbar", but police could not immediately confirm it.
"The reason behind the attack and his profile are not known yet and are being looked into," a police source said.
Counter-terrorism officials have yet to be asked to join the investigation, a judicial source said.
Trappes is an underprivileged town situated in an overall wealthy area west of Paris. Dozens of radicalised youths from the town of about 30,000 habitants have left for Syria.
Islamic State leader Abu Bakr al-Baghdadi, in his first purported speech in nearly a year, has called on followers to fight on despite recent defeats, according to an audio recording posted on the group's media outlet on Wednesday.