1

I'm currently making my first game in Python 3.5 with a friend for a school project. We are using pygame, and it was working fine until I change my computer for Ubuntu 16. I installed PyCharm. I could see that it was pointing that some things like pygame.init() were flaged as "Cannot find reference 'init' in '__init__.py'". I googled the message and it turned out it was a PyCharm bug with pygame.

But when I run my app, one of the warnings turns out not to be a bug : 'NoneType' object has no attribute 'music'. So Python doesn't find the mixer module for pygame, though I wrote import pygame in the concerned file :

    import pygame
....
    def play_music(self):
        pygame.mixer.music.load(<mymusic>)
        pygame.mixer.music.play()

Thank you for your help :)

-- EDIT -- I used print(pygame.mixer) to verify its value was None. I received :

<module 'pygame.mixer' from '/home/<myname>/.local/lib/python3.5/site-packages/pygame/mixer.cpython-35m-x86_64-linux-gnu.so'>
CodingMouse
  • 63
  • 14
  • Maybe the `.mixer` is the problem? Can you print `pygame.mixer` and see if it outputs none? – Adam Hughes May 25 '17 at 14:55
  • Are you using the latest version of `pygame` (v 1.9.2)? – HEADLESS_0NE May 25 '17 at 15:00
  • do you not need to set `pygame.mixer.music.load()` to a variable and just call `myvariable.play()` – tushortz May 25 '17 at 15:02
  • @HEADLESS_0NE we are on 1.9.3 – CodingMouse May 25 '17 at 15:07
  • The [docs](http://www.pygame.org/docs/ref/mixer.html#module-pygame.mixer) for `pygame.mixer` mention the following: "This module contains classes for loading Sound objects and controlling playback. **The mixer module is optional and depends on SDL_mixer. Your program should test that pygame.mixerpygame module for loading and playing sounds is available and intialized before using it**." – HEADLESS_0NE May 25 '17 at 15:19
  • @CodingMouse do you have the SDL Mixer installed? If not, his is likely what is missing: https://www.libsdl.org/projects/SDL_mixer/ – HEADLESS_0NE May 25 '17 at 15:22

0 Answers0