Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pygame,加载.wav文件内存错误_Python_Pygame - Fatal编程技术网

Python pygame,加载.wav文件内存错误

Python pygame,加载.wav文件内存错误,python,pygame,Python,Pygame,我在conf.py文件中编写了代码 env_sound = pygame.mixer.Sound('resources/sound/env.wav') 在game.py文件中,我只是import conf env_sound = conf.env_sound 错误是 File "/path/game.py", line 8, in <module> import conf File "/path/conf.py", line 45, in <module>

我在
conf.py
文件中编写了代码

env_sound = pygame.mixer.Sound('resources/sound/env.wav')
game.py
文件中,我只是
import conf

env_sound = conf.env_sound
错误是

File "/path/game.py", line 8, in <module>
    import conf
File "/path/conf.py", line 45, in <module>
    env_sound = pygame.mixer.Sound('resources/sound/env.wav')

MemoryError
文件“/path/game.py”,第8行,在
导入配置
文件“/path/conf.py”,第45行,在
env_sound=pygame.mixer.sound('resources/sound/env.wav'))
记忆者
game.py
conf.py
在同一个目录中

env.wav
的大小约为511KB,我认为这不会导致内存错误


有什么问题吗?

您需要初始化
pygame.mixer
使其工作。因此,大致如下:

#add this somewhere before env_sound = pygame.mixer.Sound('resources/sound/env.wav')
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)

阅读以获得进一步的参考。

您需要初始化
pygame.mixer
以使其工作。因此,大致如下:

#add this somewhere before env_sound = pygame.mixer.Sound('resources/sound/env.wav')
pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=4096)
请阅读以下内容以供进一步参考