简体   繁体   English

"ImportError:没有名为“geopy”的模块 ipython-notebook"

[英]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):为此,我在 ipython-notebook(版本 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)

You need to install the missing module in your python installation. 您需要在python安装中安装缺少的模块。 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: 如果您没有pip,则必须使用以下命令安装它:

easy_install pip

and if both command fail with Permission denied , then you'll have to either launch the command as root: 如果两个命令都失败且Permission denied ,那么你必须以root身份启动命令:

sudo easy_install pip
sudo pip install geopy

or for pip, install it only for your user: 或者为pip,只为您的用户安装:

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在pypi上搜索它:

% 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 HTH

即使您使用 pip install 命令安装,您仍然必须在 anaconda 服务器中使用 conda install -c conda-forge geopy 此命令,以便将其安装在 anaconda 中。

"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM