random関数を利用しようとしたらタイトルのエラー
・(random.pyというファイル名で作成していたので)ファイル名の変更
・シンボリックリンクの作成
でエラーが解消した
root@hostname:/home/shimizu/python# cat random.py
import random
if __name__ == "__main__":
print random.random()
root@hostname:/home/shimizu/python# python random.py
Traceback (most recent call last):
File "random.py", line 3, in <module>
print random.random()
TypeError: 'module' object is not callable
root@hostname:/home/shimizu/python# mv random.py mkrandom.py
root@hostname:/home/shimizu/python# python mkrandom.py
Traceback (most recent call last):
File "mkrandom.py", line 3, in <module>
print random.random()
TypeError: 'module' object is not callable
root@hostname:/home/shimizu/python# ln -s /usr/lib/python2.7/random.py ./
root@hostname:/home/shimizu/python# python mkrandom.py
0.228268881195
参考URL
help with python urllib2 import error
http://stackoverflow.com/questions/1933928/help-with-python-urllib2-import-error#comment1842908_1933953