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

Issue with graph_from_bbox on Visual Studio code. #1180

Closed
3 tasks done
QuentinMV opened this issue Jun 3, 2024 · 5 comments · Fixed by #1182
Closed
3 tasks done

Issue with graph_from_bbox on Visual Studio code. #1180

QuentinMV opened this issue Jun 3, 2024 · 5 comments · Fixed by #1182
Labels

Comments

@QuentinMV
Copy link

Contributing guidelines

  • I understand the contributing guidelines

Documentation

  • My problem is not addressed by the documentation or examples

Existing issues

  • My problem does not appear in an existing issue

What operating system and Python version are you using?

Windows 11 / Python 3.12

What OSMnx version are you using?

osmx 1.8.1 & latest version 2.0

Environment packages and versions

Azur/databricks and Visual Studio code/jupyter
Both latest version ( 03/06/2024 )

How did you install OSMnx?

Pip

Problem description

First of all, english is not my main language so sorry for poor vocabulary.

Hi everyone,

I'm having some issues and i hope someone can help me. Im coding on 2 environnements ( databricks & visual studio code/jupyter ). I use osmnx to create graph to find the shortest path between 2 points. Everything works well on databricks but i have problems in Visual on this line : graph = ox.graph_from_bbox(north=north, south=south, east=east, west=west, network_type="all"). I have a futur warning, which is not very important for now ( I suppose ), but this warning :

UnboundLocalError: cannot access local variable 'response' where it is not associated with a value

I dont know where it comes from, because everything works well on databricks, i checked the proxy on visual, everything ok.
I made some research and the issue might be an SSL issue, i checked how to solve it but in this case i need to manually Specify Certificate Path but i don't see where i can find the path osmnx.

I'm not sure if my issue is connected to osmx but if you can help me, or just say the problem is not from osmx it will help me a lot !

Thanks.

Futur warning :

Complete minimal reproducible example

( pip osmx )

import osmnx as ox
graph = ox.graph_from_bbox(north=40, south=40.1, east=39.9, west=40.2, network_type="all")
@QuentinMV QuentinMV added the bug label Jun 3, 2024
@QuentinMV
Copy link
Author

*Futur warning : *
FutureWarning: The north, south, east, and west parameters are deprecated and will be removed in the v2.0.0 release. Use the bbox parameter instead. See the OSMnx v2 migration guide: #1123
graph = ox.graph_from_bbox(north=40, south=40.1, east=39.9, west=40.2, network_type="all"

@gboeing
Copy link
Owner

gboeing commented Jun 3, 2024

  1. Please provide your complete error traceback for the UnboundLocalError.

  2. Does the same UnboundLocalError occur on 1.8.1 and 2.0.0b0?

@gboeing
Copy link
Owner

gboeing commented Jun 3, 2024

I am unable to reproduce an UnboundLocalError using your code and OSMnx 1.8.1 or 2.0.0 beta.

If you provide the complete error traceback you're getting, I can take a look.

@QuentinMV
Copy link
Author

QuentinMV commented Jun 4, 2024

I am unable to reproduce an UnboundLocalError using your code and OSMnx 1.8.1 or 2.0.0 beta.

If you provide the complete error traceback you're getting, I can take a look.

Hi,

First of all, thanks you for your response, i had the error on 1.8.1, so i dowloaded the 2.0 version, same error.

Complete error :

SSLCertVerificationError                  Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python312\site-packages\urllib3\connectionpool.py:467, in HTTPConnectionPool._make_request(self, conn, method, url, body, headers, retries, timeout, chunked, response_conn, preload_content, decode_content, enforce_content_length)
    [466](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connectionpool.py:466) try:
--> [467](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connectionpool.py:467)     self._validate_conn(conn)
    [468](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connectionpool.py:468) except (SocketTimeout, BaseSSLError) as e:

File ~\AppData\Roaming\Python\Python312\site-packages\urllib3\connectionpool.py:1099, in HTTPSConnectionPool._validate_conn(self, conn)
   [1098](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connectionpool.py:1098) if conn.is_closed:
-> [1099](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connectionpool.py:1099)     conn.connect()
   [1101](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connectionpool.py:1101) # TODO revise this, see https://github.com/urllib3/urllib3/issues/2791

File ~\AppData\Roaming\Python\Python312\site-packages\urllib3\connection.py:653, in HTTPSConnection.connect(self)
    [651](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:651) server_hostname_rm_dot = server_hostname.rstrip(".")
--> [653](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:653) sock_and_verified = _ssl_wrap_socket_and_match_hostname(
    [654](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:654)     sock=sock,
    [655](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:655)     cert_reqs=self.cert_reqs,
    [656](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:656)     ssl_version=self.ssl_version,
    [657](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:657)     ssl_minimum_version=self.ssl_minimum_version,
    [658](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:658)     ssl_maximum_version=self.ssl_maximum_version,
    [659](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:659)     ca_certs=self.ca_certs,
    [660](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:660)     ca_cert_dir=self.ca_cert_dir,
    [661](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:661)     ca_cert_data=self.ca_cert_data,
    [662](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:662)     cert_file=self.cert_file,
    [663](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/urllib3/connection.py:663)     key_file=self.key_file,
...
    [142](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/osmnx/_overpass.py:142)     return default_duration
    [143](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/osmnx/_overpass.py:143) except (AttributeError, IndexError, ValueError):  # pragma: no cover
    [144](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/qmart261/OneDrive%20-%20Cafdoc/Documents/Visual/creche/~/AppData/Roaming/Python/Python312/site-packages/osmnx/_overpass.py:144)     # cannot parse output, log error and return default duration

UnboundLocalError: cannot access local variable 'response' where it is not associated with a value

@gboeing
Copy link
Owner

gboeing commented Jun 4, 2024

Two things happening here.

  1. there's a bug where we're accessing the response variable in an except block, but the exception occurred before response was defined. Fixed in fix accessing response var before definition #1182

  2. The requests package is giving you an SSL error, likely due to your proxy. See the requests docs for details. You can configure the requests_kwargs setting in OSMnx: https://osmnx.readthedocs.io/en/latest/user-reference.html#module-osmnx.settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants