Python CSV Has No Attribute 'Writer'

For me I had named my file csv.py. So when I import csv from that file I was essentially trying to import the same file itself.


If you've set something that assigns to csv (looks like a string) then you're shadowing the module import. So, the simplest thing is to just change whatever's assigning to csv that isn't the module and call it something else...

In effect what's happening is:

import csv
csv = 'bob'
csvout = csv.writer(somefile)

Remove the further assignment to csv and go from there...