简体   繁体   English

Python WinRT 地理位置运行时错误

[英]Python WinRT Geolocation RuntimeError

I am trying to read the geocoordinates from my windows device using the WinRT API with the solution suggested in this post :我正在尝试使用 WinRT API 以及本文中建议的解决方案从我的 windows 设备中读取地理坐标:

import winrt.windows.devices.geolocation as wdg, asyncio

async def getCoords():
    locator = wdg.Geolocator()
    pos = await locator.get_geoposition_async()
    print(pos)
    return [pos.coordinate.latitude, pos.coordinate.longitude]
    
asyncio.run(getCoords())

Unfortunately, I run into the following error...not much to go on:不幸的是,我遇到了以下错误......对 go 来说并不多:

Traceback (most recent call last):
  File "C:\path\to\locator.py", line 9, in <module>
    asyncio.run(getCoords())
  File "C:\path\to\anaconda3\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\path\to\anaconda3\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "C:\path\to\locator.py", line 5, in getCoords
    pos = await locator.get_geoposition_async()
RuntimeError

I've also tried the exact solution in the WinRT Documentation without much luck.我也尝试过WinRT 文档中的确切解决方案,但运气不佳。

This solution worked for me about a year ago.大约一年前,这个解决方案对我有用。 I have since switched from Windows 10 to Windows 11. Is it possible this is a Windows 11 issue?我已经从 Windows 10 切换到 Windows 11。这可能是 Windows 11 问题吗?

winrt is no longer maintained, you can use the community-supported winsdk fork. winrt 不再维护,您可以使用社区支持的winsdk fork。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM