Examples returning ERRORs
Running the 1rst example in README:
"Exception has occurred: ClientConnectorError Cannot connect to host cbk0.google.com:443 ssl:default [The semaphore timeout period has expired] OSError: [WinError 121] The semaphore timeout period has expired
The above exception was the direct cause of the following exception:
File "D:\Hobby2024\GEO StreetView\streetlevel_00.py", line 4, in
Running the 2nd example: " File "D:\Hobby2024\GEO StreetView\streetlevel_async_00.py", line 4 async with ClientSession() as session: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'async with' outside async function"
Any sugestion?
The sync example works fine for me, so this may be a network issue on your end.
The async examples in this repo are written with ipython in mind, where they will work as is. With the regular Python interpreter, as stated by the error message, the async code needs to be inside an async function, like this:
import asyncio
from streetlevel import streetview
from aiohttp import ClientSession
async def main():
async with ClientSession() as session:
pano = await streetview.find_panorama_async(46.883958, 12.169002, session)
await streetview.download_panorama_async(pano, f"{pano.id}.jpg", session)
if __name__ == "__main__":
asyncio.run(main())
Thank you for your answer. Edited the 2nd example (async), now it runs but I get the same error as for the 1rst example:
line 13, in
Can you ping cbk0.google.com? If yes, what's the latency like?
Thank you for your answer. This is the ping:
D:\Hobby2024\GEO StreetView>ping cbk0.google.com
Pinging cbk-legacy.l.google.com [216.58.215.174] with 32 bytes of data: Reply from 216.58.215.174: bytes=32 time=21ms TTL=118 Reply from 216.58.215.174: bytes=32 time=21ms TTL=118 Reply from 216.58.215.174: bytes=32 time=21ms TTL=118 Reply from 216.58.215.174: bytes=32 time=21ms TTL=118
Ping statistics for 216.58.215.174: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 21ms, Maximum = 21ms, Average = 21ms
While running example_1.py, to my surprise I found one image: "Km97D1NoYIySkjysrp8HMA.jpg" in the downloads folder.
Encouraged by this, I retried 200 times using the command line:
D:\Hobby2024\GEO StreetView>for /l %N in (1 1 200) do py streetlevel_example1.py & echo %N
but no luck...