gpt4 book ai didi

python - NoneType' 对象没有属性 '__getitem__'

转载 作者:行者123 更新时间:2023-11-28 20:45:14 25 4
gpt4 key购买 nike

我在 openstack 设置中尝试 nova-list cli 命令时遇到以下错误。NoneType' 对象没有属性 'getitem'

 DEBUG (shell:777) 'NoneType' object has no attribute '__getitem__'
Traceback (most recent call last):
File "/opt/stack/python-novaclient/novaclient/shell.py", line 774, in main
OpenStackComputeShell().main(map(strutils.safe_decode, sys.argv[1:]))
File "/opt/stack/python-novaclient/novaclient/shell.py", line 685, in main
self.cs.authenticate()
File "/opt/stack/python-novaclient/novaclient/v1_1/client.py", line 169, in authenticate
self.client.authenticate()
File "/opt/stack/python-novaclient/novaclient/client.py", line 382, in authenticate
auth_url = self._v2_auth(auth_url)
File "/opt/stack/python-novaclient/novaclient/client.py", line 469, in _v2_auth
return self._authenticate(url, body)
File "/opt/stack/python-novaclient/novaclient/client.py", line 484, in _authenticate
return self._extract_service_catalog(url, resp, respbody)
File "/opt/stack/python-novaclient/novaclient/client.py", line 307, in _extract_service_catalog
self.auth_token = self.service_catalog.get_token()
File "/opt/stack/python-novaclient/novaclient/service_catalog.py", line 29, in get_token
return self.catalog['access']['token']['id']
TypeError: 'NoneType' object has no attribute '__getitem__'
ERROR: 'NoneType' object has no attribute '__getitem_

_'

这是什么意思?是我的 openstack 设置有问题还是一些 python 相关的错误?

最佳答案

从字面上看,'NoneType' object has no attribute... 表示您正在尝试访问属性或调用具有值 None 的对象的方法。

实际上,这意味着您可能在某处存在错误,即在为变量赋值之前使用变量,或者使用返回 None 的函数的值。调试此问题的第一步是问自己“为什么将此变量设置为 None?”。

在此特定情况下,self.catalogself.catalog['access']self.catalog['access']['token ']None

关于python - NoneType' 对象没有属性 '__getitem__',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24119731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com