我可以運行:蟒蛇廚師在控制檯的工作不是在腳本
import chef
chef.autoconfigure()
for node in chef.Node.list():
if "auto" in node.lower():
print "deleting node " + node
nodeObj = chef.Node(node)
nodeObj.delete()
在控制檯
直接,但是當我嘗試運行它作爲一個腳本:python2.7 test.py
我收到以下錯誤:
Traceback (most recent call last):
File "test.py", line 38, in <module>
for node in chef.Node.list():
File "/usr/local/lib/python2.7/site-packages/chef/base.py", line 86, in list
names = [name for name, url in api[cls.url].iteritems()]
TypeError: 'NoneType' object has no attribute '__getitem__'
我用控制檯驗證
>>> chef.__path__
['/usr/local/lib/python2.7/site-packages/chef']
因此,機器是一樣的,蟒蛇的版本是一樣的, nd模塊是一樣的。爲什麼這可能發生?