I have problems in using the Geopy package.
I have installed it with pip and I'm using python 2.7.3.
Geopy is correctly installed under
/usr/local/lib/python2.7/dist-packages
I've tried to run a file only importing the geopy.geocoders as suggested by the Geopy's Documentation:
from geopy.geocoders import Nominatim
geolocator = Nominatim()
but I have this error:
Traceback (most recent call last):
File "geopy.py", line 1, in <module>
from geopy.geocoders import Nominatim
ImportError: No module named geocoders
I checked the python path printing sys.path() and I think it is correct because it shows me correctly
/usr/local/lib/python2.7/dist-packages/geopy
and
/usr/local/lib/python2.7/dist-packages/geopy-1.10.0.dist-info
I've also tried to uninstall and reinstall geopy, also using easy_install instead of pip but nothing changed.
Any ideas? Thank you.
The issue is your module name is geopy and thus it is higher on the PYTHONPATH than your dist-packages directory. In order to fix this, rename your python file.
In order to verify this, you can run python in verbose mode (python -v) and when importing it will tell you where it is trying to import from. In your case it should tell you it's looking in geopy.pyc as opposed to /usr/local/lib/python2.7/dist-packages/