user5446609
user5446609

Reputation: 174

ImportError: No module named 'geopy' ipython-notebook

currently I need to make some distance calculation. For this I am trying the following on my ipython-notebook (version 4.0.4):

from geopy.distance import vincenty

ig_gruendau = (50.195883, 9.115557)
delphi = (49.99908,19.84481)

print(vincenty(ig_gruendau,delphi).miles)

Unfortunately I receive the following error when running the code above: ImportError: No module named 'geopy'

Since I am pretty new at python, I wonder how can I install this module (without admin rights) or what other simple options I do have for this calculations?

Thanks, ML

Upvotes: 14

Views: 62774

Answers (3)

OptoNPO
OptoNPO

Reputation: 121

Double-check your interpreter settings.

Adding a potential solution below, especially for those running venvs through VS Code. A fresh VSC install put me back to square 1 with a number of "No Module Named" errors, which landed me on this thread.

My solution:

  1. update python/PIP as covered above
  2. enable official Python extension for VSC--not Code Runner (as I've seen suggested in a few places<< not bashing code runner--it's just that Python extension will get you going faster, especially if you're newer to development like me.
  3. Make sure your shell is activated, usually env/bin/activate, poetry shell, etc.
  4. Set your interpreter. VSC confuses folks by placing a recommendation 'star' next to your latest system/pip version of Python. If you're running a venv, be sure to select the Python version installed within your virtual environment.

enter image description here

Hope this helps--

Upvotes: 0

Kushal Shambu
Kushal Shambu

Reputation: 1

Even if you install using pip install command you still have to use:

conda install -c conda-forge geopy

This command is in the anaconda server so that it gets installed in the anaconda.

Upvotes: 0

zmo
zmo

Reputation: 24812

You need to install the missing module in your python installation. So you have to run the command:

pip install geopy

in your terminal. If you don't have pip, you'll have to install it using:

easy_install pip

and if both command fail with Permission denied, then you'll have to either launch the command as root:

sudo easy_install pip
sudo pip install geopy

or for pip, install it only for your user:

pip install geopy --user

And for future reference, whenever you get that kind of error:

ImportError: No module named 'XXXXX'

you can search for it on pypi using pip:

% pip search XXXXX

and in your case:

% pip search geopy
tornado-geopy (0.1.0)  - tornado-geopy is an asynchronous version of the awesome geopy library.
geopy.jp (0.1.0)       - Geocoding library for Python.
geopy.jp-2.7 (0.1.0)   - Geocoding library for Python.
geopy (1.11.0)         - Python Geocoding Toolbox

HTH

Upvotes: 21

Related Questions