S.Shiro
S.Shiro

Reputation: 167

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?

Upvotes: 4

Views: 8719

Answers (3)

Mark Hansen
Mark Hansen

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.

enter image description here

Upvotes: 2

hiranyajaya
hiranyajaya

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

CAPSLOCK
CAPSLOCK

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

Related Questions