Reputation: 31
I'm trying to install geopy to use in Jupyter, but I keep getting the following error when I try to import it.
import geopy
ModuleNotFoundErrorTraceback (most recent call last)
<ipython-input-1-3fa4a0b62b91> in <module>
1 import pandas as pd
2 import numpy as np
----> 3 import geopy
4
5 # Suppressing warnings
ModuleNotFoundError: No module named 'geopy'
I already installed geopy using pip install geopy
so I'm not sure why I'm getting this error.
In command line when input pip --version
I get:
pip 19.0.3 from /Library/Python/2.7/site-packages/pip-19.0.3-py2.7.egg/pip (python 2.7)
when I input pip list
:
Package Version
-------------------------------------- --------
altgraph 0.10.2
bdist-mpkg 0.5.0
bonjour-py 0.3
geographiclib 1.49
geopy 1.18.1
macholib 1.5.1
matplotlib 1.3.1
modulegraph 0.10.4
numpy 1.8.0rc1
pip 19.0.3
py2app 0.7.3
pyobjc-core 2.5.1
pyobjc-framework-Accounts 2.5.1
pyobjc-framework-AddressBook 2.5.1
pyobjc-framework-AppleScriptKit 2.5.1
pyobjc-framework-AppleScriptObjC 2.5.1
pyobjc-framework-Automator 2.5.1
pyobjc-framework-CFNetwork 2.5.1
pyobjc-framework-Cocoa 2.5.1
pyobjc-framework-Collaboration 2.5.1
pyobjc-framework-CoreData 2.5.1
pyobjc-framework-CoreLocation 2.5.1
pyobjc-framework-CoreText 2.5.1
pyobjc-framework-DictionaryServices 2.5.1
pyobjc-framework-EventKit 2.5.1
pyobjc-framework-ExceptionHandling 2.5.1
pyobjc-framework-FSEvents 2.5.1
pyobjc-framework-InputMethodKit 2.5.1
pyobjc-framework-InstallerPlugins 2.5.1
pyobjc-framework-InstantMessage 2.5.1
pyobjc-framework-LatentSemanticMapping 2.5.1
pyobjc-framework-LaunchServices 2.5.1
pyobjc-framework-Message 2.5.1
pyobjc-framework-OpenDirectory 2.5.1
pyobjc-framework-PreferencePanes 2.5.1
pyobjc-framework-PubSub 2.5.1
pyobjc-framework-QTKit 2.5.1
pyobjc-framework-Quartz 2.5.1
pyobjc-framework-ScreenSaver 2.5.1
pyobjc-framework-ScriptingBridge 2.5.1
pyobjc-framework-SearchKit 2.5.1
pyobjc-framework-ServiceManagement 2.5.1
pyobjc-framework-Social 2.5.1
pyobjc-framework-SyncServices 2.5.1
pyobjc-framework-SystemConfiguration 2.5.1
pyobjc-framework-WebKit 2.5.1
pyOpenSSL 0.13.1
pyparsing 2.0.1
python-dateutil 1.5
pytz 2013.7
scipy 0.13.0b1
setuptools 18.5
six 1.4.1
xattr 0.6.4
Upvotes: 2
Views: 5478
Reputation: 31
i encountered the same problem and now i fixed it. so in top part of jupyter notebook click kernel then you change kernel into a different python interpretur (that has geopy package). if you have only 1 interpreter here is how you create a new one.
open your command prompt (terminal in your computer). and create new enviroment.
follow these steps: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
when you created new enviroment close your command promt and open again:
then refresh your screen open your jupyter notebook change kernel. you should see your conda enviroment. if you don't see it or confused at any of the steps contact me via instagram: @raxham_habs_01
Upvotes: 3
Reputation: 120
OK I had a bit of a headache with this as I was doing a training program and the guy who was showing did not have it accurate.
Here are some links and suggestions to try to fix. I was using Anaconda for the Jupyter Notebook.
From "https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/pqFuJBDcBb4" one of the last comments had the command.
So just open Anaconda CLI prompt as Administrator.
conda install -c conda-forge geopy
Once you have done that you have to ensure you are using the right syntax as some of it has changed from the "tutorials" out there. Here is a great explanation: https://github.com/geopy/geopy
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="My_geolocate")
lookingFor = "Moscow"
locations = geolocator.geocode(lookingFor)
print(locations)
RESULTS:
Locating Moscow
Москва, Центральный федеральный округ, Россия
If you want returned location in English:
locations = geolocator.geocode(lookingFor, language="en")
References: https://anaconda.org/conda-forge/geopy https://github.com/geopy/geopy
Upvotes: 0