Python WinRT 地理定位运行时错误
我正在尝试使用 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())
不幸的是,我遇到以下错误...没什么可继续的:
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
我也尝试了 WinRT 文档 运气不佳。
大约一年前,这个解决方案对我有用。我已从 Windows 10 切换到 Windows 11。这是否可能是 Windows 11 问题?
I am trying to read the geocoordinates from my windows device using the WinRT API with the solution suggested in this post:
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:
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.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
winrt 不再维护,您可以使用社区支持的 winsdk 分支。
winrt is no longer maintained, you can use the community-supported winsdk fork.