简体   繁体   English

挣扎着 geopy 安装。 ModuleNotFoundError:没有名为“geopy.geocoders”的模块

[英]Struggling with geopy install. ModuleNotFoundError: No module named 'geopy.geocoders'

I ran pip install geopy and it seemed to install ok, but I couldn't run the following script.我运行了pip install geopy ,它似乎安装正常,但我无法运行以下脚本。

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="ryan_data")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)

That script gives me this.那个剧本给了我这个。

Traceback (most recent call last):

  File "C:\Users\ryans\AppData\Local\Temp\ipykernel_19160\137417210.py", line 1, in <module>
    from geopy.geocoders import Nominatim

  File "C:\Users\ryans\geopy.py", line 3, in <module>
    from geopy.geocoders import Nominatim

ModuleNotFoundError: No module named 'geopy.geocoders'; 'geopy' is not a package

I also tried the following three lines to get geopy installed;我还尝试了以下三行来安装 geopy; none worked.没有工作。

conda install -c conda-forge geopy
conda install -c conda-forge geopy=2.3.0
conda install -c conda-forge geopandas=0.10

The geopy package works fine on another computer that I use, but it doesn't seem to install on the laptop that I am using now. geopy package 在我使用的另一台计算机上运行良好,但它似乎没有安装在我现在使用的笔记本电脑上。 Has anyone encountered this issue before?有没有人遇到过这个问题? Any idea how I can get this package installed?知道如何安装这个 package 吗?

Looking at the error traceback, you have a file named geopy.py.查看错误回溯,您有一个名为 geopy.py 的文件。 Your script is attempting to load that file instead of the geopy package.您的脚本正在尝试加载该文件而不是 geopy package。

Rename the geopy.py file to something else.将 geopy.py 文件重命名为其他名称。

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

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