简体   繁体   中英

module attribute found when using ipython notebook, not in shell

I run a very simple piece of code, which works in ipython notebook, but doesn't run in the windows command prompt when I call python or ipython (on the same machine). The error I get in the shell is "AttributeError: 'module' object has no attribute 'search' .

import reverse_geocode
coordinates = (-37.81, 144.96), (31.76, 35.21)
reverse_geocode.search(coordinates)

What could cause this?

In case this is useful in understanding the problem: I initially installed python using Anacondas. I recently installed reverse_geocode using pip. It is possible that I later installed and removed another distribution of python by mistake. Using the shell's where command, I see that both python and ipython direct toward my Anaconda distribution, which is correct.

My mistake was calling my python script the same thing as the module I am importing. The import command then imports the script itself, rather than the intended module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM