2

No matter what attribute I put alongside G = ox.________( ) it returns with an attribute error.

Currently the first part of my code is:

import osmnx as ox

place = ["Grand Rapids, MI"]
G = ox.graph_from_place(place, retain_all=True, simplify=True, network_type='all')

u = []
v = []
key = []
data = []
for uu, vv, kkey, ddata in G.edges(keys=True, data=True):

I've installed conda and the the exec file correctly. I have the latest osmnx update.

here's the debug info for ox.graph_from_place

and the debug info for ox.graph.graph_from_place

Ambush3
  • 118
  • 1
  • 7
  • That's supposed to work. Can you do `ox.graph.graph_from_place`? – Tim Roberts May 08 '21 at 03:44
  • OK, here's my sophisticated guess. My guess is you have a local file called "osmnx.py". Python will pick that one instead of the installed module. – Tim Roberts May 08 '21 at 03:50
  • I wondered that too when searching through other questions relating to the same errors. I'll have to search my files and see if I can find anything. So far nothing. – Ambush3 May 08 '21 at 03:52

2 Answers2

2

You probably have a file named osmnx.py in your working directory that is getting imported instead. Rename it and try again. See also https://stackoverflow.com/a/64633277/7321942

gboeing
  • 5,691
  • 2
  • 15
  • 41
  • In my code I printed print(ox) and it just says It doesn't show me where the osmnx.py file is located. I checked my directory and didn't see any copies of osmnx.py there. – Ambush3 May 08 '21 at 14:17
  • Try this. Open your computer's built-in terminal/command prompt (not your IDE software), change directories to your project's working folder, and run `python -c "import osmnx; print(osmnx)"`. Then please add a comment here in which you paste the complete output verbatim. – gboeing May 08 '21 at 19:23
  • After doing exactly what you said. It prints out – Ambush3 May 09 '21 at 00:52
  • I'm not sure what changed exactly. I ended up just reinstalling conda and osmnx. Updated conda and updated all the packages (it wouldn't allow me to do that before). Just so happens after doing that, that it worked. I appreciate your help. Thanks Professor! – Ambush3 May 09 '21 at 01:18
-1

Should not it be ox.graph.graph_from_place()?

Please check the below documentation:

https://osmnx.readthedocs.io/en/stable/osmnx.html#osmnx.graph.graph_from_place

Vikash Kumar
  • 177
  • 1
  • 9
  • I've done that as well and that still returns the same attribute error unfortunately. It goes from saying "osmnx has no attribute graph_from_place", to "osmnx has no attribute graph" – Ambush3 May 08 '21 at 03:46
  • If you check the osmnx documentation, they import virtually all of their APIs into the root namespace. His code should have worked. – Tim Roberts May 08 '21 at 03:50