Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved import csv Pydev Eclipse

I have a love-hate relationship with Pydev on Eclipse. For some reason it is now telling me that it has an unresolved import on the code:

import csv

Traceback (most recent call last):
  File "/Users/peterstannett/Documents/Programming/python/eclipse/workspace/myFirstPydev/csv.py", line 1, in <module>
import csv
  File "/Users/peterstannett/Documents/Programming/python/eclipse/workspace/myFirstPydev/csv.py", line 3, in <module>
cr = csv.reader(f)
AttributeError: 'module' object has no attribute 'reader'

It was working fine a few days ago I'm sure!

So I started to look at the interpreter and the path where the csv.py file should be and I can see in the System PYTHONPATH that it has the /lib/python2.7 where the csv.py file is held yet I still get an error.

enter image description here

Would someone please help me resolve this as it is most frustrating!

Thanks

like image 515
Peter Stannett Avatar asked Jan 07 '12 12:01

Peter Stannett


1 Answers

Since your file is called csv.py, it is found before the csv module from the standard library when you import csv. Rename your file to something like myCsv.py to resolve the ambiguity.

like image 104
phihag Avatar answered Nov 04 '22 21:11

phihag