简体   繁体   English

Python Geopy安装

[英]Python geopy install

I am trying to install Geopy in Python. 我正在尝试在Python中安装Geopy。 How do I do this in really simple terms? 我如何用非常简单的方式做到这一点? I have Python 3.4.0 launcher installed. 我安装了Python 3.4.0启动器。 Where do I write the Geopy install command? 我在哪里编写Geopy安装命令? On a text file with a .py extension? 在扩展名为.py的文本文件上? Or in Terminal? 还是在航站楼? I have read to ways to install Geopy, using easy-install and pip. 我已阅读使用易安装和pip安装Geopy的方法。 Which one should I use? 我应该使用哪一个? Below is one example I have read: 以下是我已阅读的一个示例:

mkdir -p $HOME/lib/pythonX.Y, where X.Y is the Python version, and press Enter.
easy_install-X.Y package, where package is the name of the package to install, and press Enter.

Below is another installation I have read: 以下是我已阅读的另一项安装:

pip install geopy

>>> from geopy.geocoders import Nominatim
>>> geolocator = Nominatim()
>>> location = geolocator.geocode("175 5th Avenue NYC")
>>> print(location.address)
Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ...
>>> print(location.latitude, location.longitude)
(40.7410861, -73.9896297241625)
>>> print(location.raw)
{u'place_id': u'9167009604', u'type': u'attraction', ...}

So, in the above code, where am I writing this, because this is printing the result upon request? 那么,在上面的代码中,我在哪里写这个,因为这是根据请求打印结果? In Terminal? 在航站楼吗? I have the Python launcher but I can't seem to write a new script within it, it just loads text files with the .py extension. 我有Python启动器,但似乎无法在其中启动新脚本,它只加载扩展名为.py的文本文件。

Apologies for the asking about the basics here. 很抱歉在这里询问基本知识。 Very much a novice. 非常新手。 If anyone could explain how I could install Geopy and execute the above geocoding technique in a step-by-step way, it would be very much appreciated. 如果有人能解释我如何安装Geopy并逐步执行上述地理编码技术,将不胜感激。

Assuming you have pip installed (as miles mentioned), in terminal, type: 假设您已经安装了pip(如前所述),请在终端中输入:

pip install geopy

Then you should be able to use the geopy module in python. 然后,您应该能够在python中使用geopy模块。 Try from terminal 从终端尝试

python
>>> from geopy.geocoders import Nominatim
>>> geolocator = Nominatim()
...etc

Python 3.4 comes with pip so you should be able to do the following in the command line: Python 3.4附带了pip,因此您应该能够在命令行中执行以下操作:

python -m pip install geopy

If that doesn't work, try running this first: 如果那不起作用,请尝试首先运行此命令:

python -m ensurepip

Assuming you're trying to install on windows. 假设您尝试在Windows上安装。 This is how I have done. 这就是我所做的。 Prerequisite: pip ( Else find here, how to install it ) 先决条件:pip( 其他在这里找到,如何安装

  1. Step 1: Run cmd as Administrator 步骤1:以管理员身份运行cmd
  2. Step 2: cd .. 步骤2:cd ..
  3. Step 3: cd .. // you're now in root 步骤3:cd .. //您现在已经是根用户
  4. Step 4: pip install geopy 第4步:pip安装geopy

Though it's been late to answer. 尽管回答来迟了。 Hope it helps somebody. 希望它能帮助到别人。

这就是你的看法

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

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