0

I am using pipenv to install packages and create my virtual environment within my project repo. I am able to install geopy and confirm its installation using pipenv graph, but when I go into my pipenv shell and open jupyter notebook and try to import geopy I get ImportError: No module named geopy. I can only get geopy to import by running ! pip install geopy within a jupyter notebook cell. Any ideas why jupyter notebook is not recognizing my pipenv install of geopy?

  • How do you start the notebook? You're probably starting it using a Python executable that is not used by the virtual environment. –  Nov 01 '17 at 22:03
  • within the pipenv shell I run `jupyter notebook`. I was able to get geopy to import within jupyter notebook by specifying the specific version of geopy, so I went and did that for my `haversine` import as well but now I am not able to import `haversine` within my jupyter notebook cell. – sharkattacked Nov 01 '17 at 23:03

1 Answers1

0

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

John B
  • 120
  • 1
  • 9