windows - Any way to see where python is importing a module from? -
so installed facebook module, realized wrong one, used pip uninstall , installed facebook-sdk. here code:
import facebook token = '[token]' graph = facebook.graphapi(token) profile = graph.get_object("me") friends = graph.get_connections("me", "friends") friend_list = [friend['name'] friend in friends['data']] print friend_list
and
traceback (most recent phone call last): file "c:\users\mgraves\desktop\facebook.py", line 1, in <module> import facebook file "c:\users\mgraves\desktop\facebook.py", line 5, in <module> graph = facebook.graphapi(token) attributeerror: 'module' object has no attribute 'graphapi'
when looking up, every result says uninstall facebook , facebook-sdk , reinstall facebook-sdk. , have, many many times. searched /python27/ facebook afterwards create sure files gone.
is there way on windows machine trace importing "facebook" from?
module objects have __file__
attribute, , object representation includes file:
print facebook print facebook.__file__
in case, importing your own script; named facebook
, masking installed module:
file "c:\users\mgraves\desktop\facebook.py", line 1, in <module> import facebook file "c:\users\mgraves\desktop\facebook.py", line 5, in <module> graph = facebook.graphapi(token)
note filename in first line, fact same file used import. python stores main script __main__
, importing script results in module beingness created actual filename.
python windows python-2.7
No comments:
Post a Comment