Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: 'module' object is not callable when importing glob in Eclipse

I am working with Eclipse Kepler(2013) and python 3.3.2 and running a simple import like

import glob
a = glob.glob('*')
print(a)

gives a:

TypeError: 'module' object is not callable

This is not the case if I run the same code in Idle. I know I am missing something.

Any help is appreciated.

like image 383
rearThing Avatar asked Sep 06 '13 12:09

rearThing


3 Answers

In some cases people end up using same file name as built in modules. Don't name your file as "glob.py".

like image 150
saurabh agarwal Avatar answered Sep 26 '22 11:09

saurabh agarwal


What worked for me was i changed import glob to from glob import glob at the top of the file.

like image 31
Nick Avatar answered Sep 23 '22 11:09

Nick


Probably in your Eclipse environment there's a module named glob that gets imported before the standard library one.

Try printing the glob.__file__ to check it out.

like image 33
Paolo Casciello Avatar answered Sep 22 '22 11:09

Paolo Casciello