sk-zk / streetlevel

download panoramas and metadata from Street View, Look Around, and more
https://streetlevel.readthedocs.io
MIT License
49 stars 11 forks source link

Examples returning ERRORs #23

Open recursos opened 2 hours ago

recursos commented 2 hours ago

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 streetview.download_panorama(pano, f"{pano.id}.jpg") aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host cbk0.google.com:443 ssl:default [The semaphore timeout period has expired]"

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?

sk-zk commented 2 hours ago

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())
recursos commented 1 hour ago

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 asyncio.run(main()) aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host cbk0.google.com:443 ssl:default [The semaphore timeout period has expired]