yawpitch/spacedinvaders

pip install fails on Ubuntu 20.04

Closed this issue · 4 comments

pip install fails on Ubuntu 20.04. Output below.

Note: Ubuntu/Debian uses commands pip3/python3, not pip/python.

pip3 install --user spacedinvaders
Collecting spacedinvaders
  Using cached spacedinvaders-0.0.3-py3-none-any.whl (156 kB)
Collecting simpleaudio
  Using cached simpleaudio-1.0.4.tar.gz (2.0 MB)
Building wheels for collected packages: simpleaudio
  Building wheel for simpleaudio (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rv1lduy2/simpleaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rv1lduy2/simpleaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-8muw9tlo
       cwd: /tmp/pip-install-rv1lduy2/simpleaudio/
  Complete output (25 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/simpleaudio
  copying simpleaudio/__init__.py -> build/lib.linux-x86_64-3.8/simpleaudio
  copying simpleaudio/shiny.py -> build/lib.linux-x86_64-3.8/simpleaudio
  copying simpleaudio/functionchecks.py -> build/lib.linux-x86_64-3.8/simpleaudio
  creating build/lib.linux-x86_64-3.8/simpleaudio/test_audio
  copying simpleaudio/test_audio/c.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
  copying simpleaudio/test_audio/e.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
  copying simpleaudio/test_audio/g.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
  copying simpleaudio/test_audio/left_right.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
  copying simpleaudio/test_audio/notes_2_16_44.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
  running build_ext
  building 'simpleaudio._simpleaudio' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/c_src
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DDEBUG=0 -I/usr/include/python3.8 -c c_src/simpleaudio_alsa.c -o build/temp.linux-x86_64-3.8/c_src/simpleaudio_alsa.o
  c_src/simpleaudio_alsa.c:8:10: fatal error: alsa/asoundlib.h: No such file or directory
      8 | #include <alsa/asoundlib.h>
        |          ^~~~~~~~~~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for simpleaudio
  Running setup.py clean for simpleaudio
Failed to build simpleaudio
Installing collected packages: simpleaudio, spacedinvaders
    Running setup.py install for simpleaudio ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rv1lduy2/simpleaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rv1lduy2/simpleaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-89klbm5n/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/simpleaudio
         cwd: /tmp/pip-install-rv1lduy2/simpleaudio/
    Complete output (25 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/simpleaudio
    copying simpleaudio/__init__.py -> build/lib.linux-x86_64-3.8/simpleaudio
    copying simpleaudio/shiny.py -> build/lib.linux-x86_64-3.8/simpleaudio
    copying simpleaudio/functionchecks.py -> build/lib.linux-x86_64-3.8/simpleaudio
    creating build/lib.linux-x86_64-3.8/simpleaudio/test_audio
    copying simpleaudio/test_audio/c.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
    copying simpleaudio/test_audio/e.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
    copying simpleaudio/test_audio/g.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
    copying simpleaudio/test_audio/left_right.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
    copying simpleaudio/test_audio/notes_2_16_44.wav -> build/lib.linux-x86_64-3.8/simpleaudio/test_audio
    running build_ext
    building 'simpleaudio._simpleaudio' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/c_src
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DDEBUG=0 -I/usr/include/python3.8 -c c_src/simpleaudio_alsa.c -o build/temp.linux-x86_64-3.8/c_src/simpleaudio_alsa.o
    c_src/simpleaudio_alsa.c:8:10: fatal error: alsa/asoundlib.h: No such file or directory
        8 | #include <alsa/asoundlib.h>
          |          ^~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rv1lduy2/simpleaudio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rv1lduy2/simpleaudio/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-89klbm5n/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/simpleaudio Check the logs for full command output.

Hmm, looks like you're missing ALSA entirely ... looking at the simpleaudio docs it looks like on Debian you'll need to try sudo apt-get install -y python3-dev libasound2-dev.

That said I've just put a new release on pypy that makes sound optional ... try to install now with pip install spacedinvaders and you'll get silence, but pip install spacedinvaders[SOUNDS] will give you sound support, if you can get simpleaudio working properly!

Hope that helps,

M

Installing libasound2-dev resolved the build issue, and the program executed and played successfully.

However, a new issue arose, possibly when a sound announcing my demise was supposed to play.

  File "/usr/local/bin/spacedinvaders", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/__init__.py", line 1514, in main
    curses.wrapper(partial(mainloop, use_sound=opts.use_sound))
  File "/usr/lib/python3.8/curses/__init__.py", line 105, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/__init__.py", line 1468, in mainloop
    if play(stdscr, use_sound) == Control.QUIT:
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/__init__.py", line 1207, in play
    state.mystery.move(stdscr, state.frame, width, height)
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/units.py", line 346, in move
    self.x = self.wall(new_x, 0)
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/units.py", line 1184, in wall
    self.die()
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/units.py", line 1198, in die
    self.silence()
  File "/usr/local/lib/python3.8/dist-packages/spacedinvaders/units.py", line 1151, in silence
    if self.use_sound and self._sound.is_playing():
AttributeError: 'NoneType' object has no attribute 'is_playing'

Hmm, interesting ... never came up for me, but there was a bit of a race condition there. Just pushed a new release 0.0.5, try pip uninstall spacedinvaders followed by another pip install --user spacedinvaders ... that should pick up the fix.

that corrected the problem. i got a new 'high' score! being 'killed' also did not produce an error.