遇到报错AttributeError: 'itertools.cycle' object has no attribute 'next'

问题

我在写下面的程序时,遇到报错提示AttributeError: 'itertools.cycle' object has no attribute 'next'

menu_options = (('Say Hello', icons.next(), hello),
                    ('Switch Icon', None, switch_icon),
                    ('A sub-menu', icons.next(), (('Say Hello to Simon', icons.next(), simon),
                                                  ('Switch Icon', icons.next(), switch_icon),
                                                 ))
                   )

解决方法

这是因为版本问题,只要将程序icon.next()改成next(icon)就好了。

    menu_options = (('Say Hello', next(icons), hello),
                    ('Switch Icon', None, switch_icon),
                    ('A sub-menu', next(icons), (('Say Hello to Simon', next(icons), simon),
                                                  ('Switch Icon', next(icons), switch_icon),
                                                 ))
                   )

 

  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据提供的引用内容,你遇到了两个不同的报错。第一个报错是在使用pyLDAvis时出现了AttributeError: module ‘pyLDAvis‘ has no attribute ‘gensim‘的错误。第二个报错是在OpenMV IDE中出现了AttributeError: 'module' object has no attribute 'LED'的错误。 针对第一个报错AttributeError: module ‘pyLDAvis‘ has no attribute ‘gensim‘,这个错误通常是由于pyLDAvis库没有正确安装或版本不兼容所导致的。解决这个问题的方法是确保你已经正确安装了pyLDAvis和gensim库,并且版本兼容。你可以尝试升级这两个库,或者重新安装它们。另外,你还可以检查一下你的代码中是否有命名冲突或者导入错误的情况。 针对第二个报错AttributeError: 'module' object has no attribute 'LED',这个错误通常是由于OpenMV IDE中的模块没有正确导入或者命名错误所导致的。解决这个问题的方法是确保你已经正确导入了OpenMV IDE中的LED模块,并且没有命名错误。你可以检查一下你的代码中是否有导入错误或者命名错误的情况。 以下是两种可能的解决方法: 1. 解决pyLDAvis报错AttributeError: module ‘pyLDAvis‘ has no attribute ‘gensim‘: - 确保你已经正确安装了pyLDAvis和gensim库,并且版本兼容。 - 尝试升级这两个库,或者重新安装它们。 - 检查你的代码中是否有命名冲突或者导入错误的情况。 2. 解决OpenMV IDE报错AttributeError: 'module' object has no attribute 'LED': - 确保你已经正确导入了OpenMV IDE中的LED模块,并且没有命名错误。 - 检查你的代码中是否有导入错误或者命名错误的情况。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值