问题描述
我已经使用conda config --prepend通道conda-forge,conda create -n ox --strict-channel-priority osmnx安装了osmnx。当我尝试使用osmnx模块时,没有一个模块在工作,例如当我在使用时:
import osmnx as ox
place_name = "Mitte,Hannover,Germany"
ox.graph_from_place(place_name,network_type='drive')
我收到错误消息:
AttributeError: module 'osmnx' has no attribute 'graph_from_place'
当我使用时:
import osmnx as ox
ox.config(use_cache=True,log_console=True)
我收到错误消息:
AttributeError: module 'osmnx' has no attribute 'config'
,依此类推。没有任何属性
我也尝试根据https://osmnx.readthedocs.io/en/stable/osmnx.html#module-osmnx.graph使用属性,但是它也没有出现相同的错误:
import osmnx as ox
place_name = "Mitte,Germany"
ox.graph.graph_from_place(place_name,network_type='all_private')
AttributeError: module 'osmnx' has no attribute 'graph'
黄牛环境的python版本是3.8.6和Spyder(4.1.4)。 您能帮我找到这些错误的解决方案吗?
解决方法
您的桌面上有一个名为osmnx.py
的文件,并且正在导入该文件而不是已安装的模块。重命名该文件。