Installing Python Packages on Leopard

Hiya, i'm trying to read in a csv and everytime i call

import csv

i get

File "csv.py", line 1, in
import csv
File "/Users/indiehead/code/dates/geodata/csv.py", line 2, in
spamReader = csv.reader(open('GB.txt'), delimiter='"', quotechar=';')
AttributeError: 'module' object has no attribute 'reader'

which sounds like the csv module never got loaded, codes real simple at this point....

import csv
spamReader = csv.reader(open('GB.txt'), delimiter='"', quotechar=';')

just trying to get python to read the file.

tried downloading the module and installing it via,

python setup.py install

went fine but still stuck here, any ideas?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Path precedence

Hi,

Are you running from within the interpreter, or? ...

In either event, I'm guessing you are in your "/Users/indiehead/code/dates/geodata" and firing up Python and getting this error. If that's the case, when you type "import csv" Python sees the local "csv.py" file and imports that. It is then looking for the "reader" method in there, which I'm guessing is not there.

Try two things, simply change the name of your file from "csv.py" to "mycsv.py" so Python fines the csv module from its builtin library, or run Python from outside of your geodata directory, which will force Python to import the builtin csv module since it doesn't see a local "csv.py" from the directory it is launched from.

Hope that helps,
-steve