Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: get() takes 1 positional argument but 2 were given #9

Closed
raphadasilva opened this issue Nov 29, 2016 · 8 comments
Closed
Labels

Comments

@raphadasilva
Copy link

raphadasilva commented Nov 29, 2016

Good morning !

I've just installed OSMnx on my laptop running on Linux SMP Debian 3.16.7-ckt25-2 (kernel release 3.16.0-4-amd64), for both versions of Python.

Now I just tested this commands :

import osmnx as ox     # worked, no problem here
ox.plot_graph(ox.graph_from_place('Modena, Italy'))

But then, got these error :

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-0d3afc68e96a> in <module>()
----> 1 ox.plot_graph(ox.graph_from_place('Modena, Italy'))

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
   1799     if isinstance(query, str) or isinstance(query, dict):
   1800         # if it is a string (place name) or dict (structured place query), then it is a single place
-> 1801         gdf_place = gdf_from_place(query, which_result=which_result, buffer_dist=buffer_dist)
   1802         name = query
   1803     elif isinstance(query, list):

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in gdf_from_place(query, gdf_name, which_result, buffer_dist)
    522 
    523     # get the data from OSM
--> 524     data = osm_polygon_download(query, limit=which_result)
    525     if len(data) >= which_result:
    526 

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in osm_polygon_download(query, limit, polygon_geojson, pause_duration)
    495 
    496     # request the URL, return the JSON
--> 497     response_json = nominatim_request(params=params, timeout=30)
    498     return response_json
    499 

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in nominatim_request(params, pause_duration, timeout, error_pause_duration)
    373         start_time = time.time()
    374         log('Requesting {} with timeout={}'.format(prepared_url, timeout))
--> 375         response = requests.get(url, params, timeout=timeout)
    376 
    377         # get the response size and the domain, log result

TypeError: get() takes 1 positional argument but 2 were given

Thanks in advance, and have a nice day !
EDIT : I'm working with an iPython notebook.

@gboeing
Copy link
Owner

gboeing commented Nov 29, 2016

What version of requests do you have installed?

@raphadasilva
Copy link
Author

I've just checked : 2.4.3 for Python 3 (I just tested the previous code with this Python version) and requests 2.12.1 for Python 2 !

@gboeing
Copy link
Owner

gboeing commented Nov 29, 2016

Make sure you have the most recent version of requests in both environments, with: pip install requests --upgrade

@raphadasilva
Copy link
Author

raphadasilva commented Nov 29, 2016

Yes, I've got the most recent version on Python 3.4 available with pip --upgrade ! It's always 2.4.3, no changes.

For Python 2.7 upgrade didn't work, but I didn't use it for these particular case.

@gboeing
Copy link
Owner

gboeing commented Nov 29, 2016

Ok. Try upgrading OSMnx to its latest beta version: 0.1b2:

pip install osmnx --upgrade --pre

I added a new piece of code that should let it work with old versions of requests, include v2.4.x.

@raphadasilva
Copy link
Author

That's nice, thank you very much !

I used also sudo pip3 install --ignore-installed requests command, because I found an "owed by OS" message very strange.

By curiosity, which requests version do you have ? I'm quite sure that 2.4.3 is the most recent on my system !

Now I've got OSMnx 0.1b2 version (just checked it), so I ran the same command but... new error :-/...

---------------------------------------------------------------------------
NetworkXPointlessConcept                  Traceback (most recent call last)
<ipython-input-2-0d3afc68e96a> in <module>()
----> 1 ox.plot_graph(ox.graph_from_place('Modena, Italy'))

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in graph_from_place(query, network_type, simplify, retain_all, truncate_by_edge, name, which_result, buffer_dist, timeout, memory, max_query_area_size, clean_periphery)
   1815     # create graph using this polygon(s) geometry
   1816     G = graph_from_polygon(polygon, network_type=network_type, simplify=simplify, retain_all=retain_all, 
-> 1817                            truncate_by_edge=truncate_by_edge, name=name, timeout=timeout, memory=memory, max_query_area_size=max_query_area_size, clean_periphery=clean_periphery)
   1818 
   1819     log('graph_from_place() returning graph with {:,} nodes and {:,} edges'.format(len(G.nodes()), len(G.edges())))

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in graph_from_polygon(polygon, network_type, simplify, retain_all, truncate_by_edge, name, timeout, memory, max_query_area_size, clean_periphery)
   1749         # truncate graph by polygon to return the graph within the polygon that caller wants
   1750         # don't simplify again - this allows us to retain intersections along the street that may now only connect 2 street segments in the network, but in reality also connect to an intersection just outside the polygon
-> 1751         G = truncate_graph_polygon(G_buffered, polygon, retain_all=retain_all, truncate_by_edge=truncate_by_edge)
   1752 
   1753         # count how many street segments in buffered graph emanate from each intersection in un-buffered graph, to retain true counts for each intersection, even if some of its neighbors are outside the polygon

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in truncate_graph_polygon(G, polygon, retain_all, truncate_by_edge)
   1320     if not retain_all:
   1321         G = remove_isolated_nodes(G)
-> 1322         G = get_largest_component(G)
   1323 
   1324     return G

/usr/local/lib/python3.4/dist-packages/osmnx/osmnx.py in get_largest_component(G, strongly)
   1098     else:
   1099         # if the graph is not connected and caller did not request retain_all, retain only the largest weakly connected component
-> 1100         if not nx.is_weakly_connected(G):
   1101             G = max(nx.weakly_connected_component_subgraphs(G), key=len)
   1102             log('Graph was not connected, retained only the largest weakly connected component ({:,} of {:,} total nodes) in {:.2f} seconds'.format(len(G.nodes()), original_len, time.time()-start_time))

/usr/local/lib/python3.4/dist-packages/networkx-1.11-py3.4.egg/networkx/algorithms/components/weakly_connected.py in is_weakly_connected(G)

/usr/local/lib/python3.4/dist-packages/networkx-1.11-py3.4.egg/networkx/utils/decorators.py in _not_implemented_for(f, *args, **kwargs)
     66                                             ' '.join(graph_types))
     67         else:
---> 68             return f(*args,**kwargs)
     69     return _not_implemented_for
     70 

/usr/local/lib/python3.4/dist-packages/networkx-1.11-py3.4.egg/networkx/algorithms/components/weakly_connected.py in is_weakly_connected(G)
    176     if len(G) == 0:
    177         raise nx.NetworkXPointlessConcept(
--> 178             """Connectivity is undefined for the null graph.""")
    179 
    180     return len(list(weakly_connected_components(G))[0]) == len(G)

NetworkXPointlessConcept: Connectivity is undefined for the null graph.

Do you prefer that I open a new issue with that and close this one ?

Thank you again for your time and advices !

@gboeing
Copy link
Owner

gboeing commented Nov 30, 2016

I'm using requests 2.12.1 in both my Python (3.5 and 2.7) environments.

Regarding the NetworkXPointlessConcept, there's an open issue for that right now: #8. Would you comment on that issue with your details as I'm working on it there?

@gboeing gboeing closed this as completed Nov 30, 2016
@gboeing gboeing added the bug label Feb 24, 2017
gboeing pushed a commit that referenced this issue Aug 10, 2020
Updating from gboeing/osmnx master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@raphadasilva @gboeing and others