首页 > 解决方案 > 调用 Life360 API 时出错 - 部分初始化的模块

问题描述

我正在尝试使用 python 3.8 venv 使用 life360 api。我正在使用来自https://github.com/harperreed/life360-python的示例代码,这似乎对其他人有用。我知道我应该直接与开发人员合作,但是我认为我遇到的问题可能更多地与我的 venv 配置有关。

这是示例代码:

# basic authorization hash (base64 if you want to decode it and see the sekrets)
# this is a googleable or sniffable value. i imagine life360 changes this sometimes. 
authorization_token = "cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRUh1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg=="

# your username and password (hope they are secure!)
username = "email@address.com"
password = "super long password"

#instantiate the API
api = life360(authorization_token=authorization_token, username=username, password=password)

#Authenticate! 
if api.authenticate():
    
    #Grab some circles returns json
    circles =  api.get_circles()
    
    #grab id
    id = circles[0]['id']
    
    #Let's get your circle!
    circle = api.get_circle(id)

当我运行它时,我收到以下错误。我已经确认我可以在安装后导入包:

File "/Users/ryanbuckner/PycharmProjects/pythonProject/Life360/venv/life360.py", line 1, in <module>
    from life360 import life360
ImportError: cannot import name 'life360' from partially initialized module 'life360' (most likely due to a circular import) (/Users/ryanbuckner/PycharmProjects/pythonProject/Life360/venv/life360.py)

有人可以为我指出正确的故障排除方向吗?

标签: python-3.xapi

解决方案


推荐阅读