Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter notebook can not find the module

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?

like image 231
S.Shiro Avatar asked Sep 18 '25 08:09

S.Shiro


2 Answers

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
like image 100
CAPSLOCK Avatar answered Sep 20 '25 00:09

CAPSLOCK


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.

enter image description here

like image 29
Mark Hansen Avatar answered Sep 19 '25 23:09

Mark Hansen