Reputation: 23
I am using VS and I am trying to run geopy, I installed all the prerequisites and get this error "ModuleNotFoundError: No module named 'geopy.geocoders'; 'geopy' is not a package"
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="http")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)
print((location.latitude, location.longitude))
print(location.raw)
What am I missing?
Upvotes: 2
Views: 6592
Reputation: 949
This error: ModuleNotFoundError: No module named 'geopy.geocoders'; 'geopy' is not a package
may also occur if you have named the main program file you created as geopy.py
and try to run it as python geopy.py
or another file has the name geopy.py
in the same folder from which you run your program. Python will consider your program file as a module and try to find something in it that is naturally not in it. About where the Python is looking for modules, see sys.path
.
In this case, rename your program file so that its name does not equal with the name of the imported module.
Upvotes: 3
Reputation: 2744
I suspect the problem lies in you installing the geopy
package in wrong version of python (The one that comes pre-installed in \AppData\Local\Microsoft\WindowsApps\python.exe
is not full install). Grab a version of python (Either anaconda or vanilla python from python website). Let it install in default location, and then point VS code version of python that comes pre-installed with windows. Install geopy
package thorugh pip install geopy, either with VS, or through cmd with conda
or pip
. This should fix your problem.
Upvotes: 2