没有更改我的代码,但它停止工作:`object has no attribute 'EOS_LOOP'`
Haven't changed my code but it stopped working: `object has no attribute 'EOS_LOOP'`
这是我的完整代码:
错误发生在名为 player
的音乐播放器上:
Traceback (most recent call last):
File "test.py", line 915, in <module>
player.eos_action = player.EOS_LOOP
AttributeError: 'Player' object has no attribute 'EOS_LOOP'
我可以确认所有的声音文件都在目录中并且我已经用 pip3、pygame 等安装了 pyglet
几个月前我的游戏还可以,但现在我回来玩它突然就不能用了。
有问题的代码只是播放器初始化和 EOS_LOOP 部分,因为我只尝试在终端的 python3 中执行此操作,即使导入了 pyglet 也无法正常工作。
是deprecated as of at least 1.2.4。
这使我相信您使用的是删除了该属性的版本。您需要阅读迁移指南或回退到旧版本。
这可以通过 pip install 指定版本来完成:
pip3 install xyz==0.1.2
EOS_LOOP
属性 已于 2015 年 3 月 7 日从 Player
类型中删除 this commit。
在删除之前,这些常量被标记为已弃用:
#: The player will pause when it reaches the end of the stream.
#:
#: :deprecated: Use `SourceGroup.advance_after_eos`
EOS_PAUSE = 'pause'
#: The player will loop the current stream continuosly.
#:
#: :deprecated: Use `SourceGroup.loop`
EOS_LOOP = 'loop'
#: The player will move on to the next queued stream when it reaches the
#: end of the current source. If there is no source queued, the player
#: will pause.
#:
#: :deprecated: Use `SourceGroup.advance_after_eos`
EOS_NEXT = 'next'
#: The player will stop entirely; valid only for ManagedSoundPlayer.
#:
#: :deprecated: Use `SourceGroup.advance_after_eos`
EOS_STOP = 'stop'
#: :deprecated:
_eos_action = EOS_NEXT
所以根据那个,你现在应该使用 SourceGroup.loop
。
由于该更改发生在 2015 年,因此很可能此后还有其他更改。所以你应该考虑升级你的代码到新版本。
这是我的完整代码:
错误发生在名为 player
的音乐播放器上:
Traceback (most recent call last):
File "test.py", line 915, in <module>
player.eos_action = player.EOS_LOOP
AttributeError: 'Player' object has no attribute 'EOS_LOOP'
我可以确认所有的声音文件都在目录中并且我已经用 pip3、pygame 等安装了 pyglet
几个月前我的游戏还可以,但现在我回来玩它突然就不能用了。
有问题的代码只是播放器初始化和 EOS_LOOP 部分,因为我只尝试在终端的 python3 中执行此操作,即使导入了 pyglet 也无法正常工作。
是deprecated as of at least 1.2.4。
这使我相信您使用的是删除了该属性的版本。您需要阅读迁移指南或回退到旧版本。
这可以通过 pip install 指定版本来完成:
pip3 install xyz==0.1.2
EOS_LOOP
属性 已于 2015 年 3 月 7 日从 Player
类型中删除 this commit。
在删除之前,这些常量被标记为已弃用:
#: The player will pause when it reaches the end of the stream.
#:
#: :deprecated: Use `SourceGroup.advance_after_eos`
EOS_PAUSE = 'pause'
#: The player will loop the current stream continuosly.
#:
#: :deprecated: Use `SourceGroup.loop`
EOS_LOOP = 'loop'
#: The player will move on to the next queued stream when it reaches the
#: end of the current source. If there is no source queued, the player
#: will pause.
#:
#: :deprecated: Use `SourceGroup.advance_after_eos`
EOS_NEXT = 'next'
#: The player will stop entirely; valid only for ManagedSoundPlayer.
#:
#: :deprecated: Use `SourceGroup.advance_after_eos`
EOS_STOP = 'stop'
#: :deprecated:
_eos_action = EOS_NEXT
所以根据那个,你现在应该使用 SourceGroup.loop
。
由于该更改发生在 2015 年,因此很可能此后还有其他更改。所以你应该考虑升级你的代码到新版本。