Reputation: 167
I am using Jupyter notebook for a project, I have been writing in vs code but recently switched to Jupyter. The code was working in vs code but, already installed the modules with pip, but I am getting import error in Jupyter notebook. For;
import reverse_geocoder
from geopy.distance import geodesic
I am getting the
No module named 'reverse_geocoder'
No module named 'geopy'
errors. How I can install these to Jupyter?
Upvotes: 4
Views: 8719
Reputation: 1062
I had this problem and it turned out that I simply had the wrong python selected within VS Code. You have to select (in the upper right) the python environment corresponding to your project.
Upvotes: 2
Reputation: 569
IF you are working on a Python3 notebook (which is running on a Python 3.x environment), try,
pip3 install geopy
Upvotes: 0
Reputation: 6483
Google is your friend.
You can find a pretty detailed solution here (I strongly suggest you to have a look at it).
Anyway, to sum up. I am assuming you wish to install directly from the Jupyter notebook. This probably means that you don't have Anaconda (otherwise I'd suggest to install through the Anaconda prompt) but I'll write down the solution also for that case.
If you do not have Anaconda then you can simply install it using pip
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install reverse_geocoder
If you have Anaconda:
# Install a conda package in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} reverse_geocoder
However, if you do have Anaconda installed you should simply open the Anaconda prompt and install the package using:
pip install reverse_geocoder
Upvotes: 5