Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
939 views
in Technique[技术] by (71.8m points)

pip install pygame on ubuntu 18.04 using pyenv/python 3.7

I've got python 3.7.0 installed on ubuntu 18.04 using pyenv and I'm trying to install pygame using pip. My procedure is:-

sudo apt-get build-dep python-pygame
pip install pygame

The last step keeps giving me:-

peter@Brian:~$ pip install pygame
Collecting pygame
  Using cached https://files.pythonhosted.org/packages/61/06/3c25051549c252cc6fde01c8aeae90b96831370884504fe428a623316def/pygame-1.9.3.tar.gz
Installing collected packages: pygame
  Running setup.py install for pygame ... error
   ...
   ...
    running build_ext
    building 'pygame.imageext' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_REENTRANT -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/usr/include -I/usr/include -I/home/peter/.pyenv/versions/3.7.0/include/python3.7m -c src/imageext.c -o build/temp.linux-x86_64-3.7/src/imageext.o
    src/imageext.c: In function ‘write_jpeg’:
    src/imageext.c:487:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (num_lines_to_write > (cinfo.image_height - cinfo.next_scanline) -1) {
                                    ^
    In file included from src/pygame.h:32:0,
                     from src/imageext.c:49:
    src/imageext.c: In function ‘opengltosdl’:
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/imageext.c:632:9: note: in expansion of macro ‘RAISE’
             RAISE (PyExc_RuntimeError, "Cannot get video surface.");
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/imageext.c:636:9: note: in expansion of macro ‘RAISE’
             RAISE (PyExc_RuntimeError, "Cannot find glReadPixels function.");
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/imageext.c:643:9: note: in expansion of macro ‘RAISE’
             RAISE (PyExc_MemoryError, "Cannot allocate enough memory for pixels.");
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/imageext.c:663:9: note: in expansion of macro ‘RAISE’
             RAISE (PyExc_SDLError, SDL_GetError ());
             ^~~~~
    gcc -pthread -shared -L/home/peter/.pyenv/versions/3.7.0/lib -L/home/peter/.pyenv/versions/3.7.0/lib build/temp.linux-x86_64-3.7/src/imageext.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lSDL -lSDL_image -lpng -ljpeg -o build/lib.linux-x86_64-3.7/pygame/imageext.cpython-37m-x86_64-linux-gnu.so
    building 'pygame.font' extension
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_REENTRANT -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/home/peter/.pyenv/versions/3.7.0/include/python3.7m -c src/font.c -o build/temp.linux-x86_64-3.7/src/font.o
    src/font.c: In function ‘font_render’:
    src/font.c:390:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (strlen(astring) != Bytes_GET_SIZE(bytes)) {
                                 ^~
    src/font.c:417:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (strlen(astring) != Bytes_GET_SIZE(text)) {
                                 ^~
    In file included from src/pygame.h:32:0,
                     from src/font.c:31:
    src/font.c: In function ‘font_init’:
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/font.c:619:9: note: in expansion of macro ‘RAISE’
             RAISE(PyExc_SDLError, "font not initialized");
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/font.c:724:9: note: in expansion of macro ‘RAISE’
             RAISE(PyExc_RuntimeError, SDL_GetError());
             ^~~~~
    gcc -pthread -shared -L/home/peter/.pyenv/versions/3.7.0/lib -L/home/peter/.pyenv/versions/3.7.0/lib build/temp.linux-x86_64-3.7/src/font.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lSDL -lSDL_ttf -o build/lib.linux-x86_64-3.7/pygame/font.cpython-37m-x86_64-linux-gnu.so
    building 'pygame.mixer' extension
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_REENTRANT -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/home/peter/.pyenv/versions/3.7.0/include/python3.7m -c src/mixer.c -o build/temp.linux-x86_64-3.7/src/mixer.o
    In file included from src/pygame.h:32:0,
                     from src/mixer.c:27:
    src/mixer.c: In function ‘_format_view_to_audio’:
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:136:9: note: in expansion of macro ‘RAISE’
             RAISE(PyExc_ValueError, "Array has unsupported item format");
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:165:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_ValueError, "Array has unsupported item format");
                 ^~~~~
    src/mixer.c: In function ‘_chunk_from_array’:
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1363:9: note: in expansion of macro ‘RAISE’
             RAISE(PyExc_SDLError, "Mixer not initialized");
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1371:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_ValueError,
                 ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1378:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_ValueError,
                 ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1383:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_ValueError,
                 ^~~~~
    src/mixer.c: In function ‘sound_init’:
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1516:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_TypeError, arg_cnt_err_msg);
                 ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1532:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_TypeError, arg_cnt_err_msg);
                 ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1555:13: note: in expansion of macro ‘RAISE’
                 RAISE(PyExc_TypeError,
                 ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1561:9: note: in expansion of macro ‘RAISE’
             RAISE(PyExc_TypeError, arg_cnt_err_msg);
             ^~~~~
    src/_pygame.h:206:46: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     #define RAISE(x,y) (PyErr_SetString((x), (y)), (PyObject*)NULL)
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
    src/mixer.c:1585:21: note: in expansion of macro ‘RAISE’
                         RAISE(PyExc_SDLError, SDL_GetError());
                         ^~~~~
    gcc -pthread -shared -L/home/peter/.pyenv/versions/3.7.0/lib -L/home/peter/.pyenv/versions/3.7.0/lib build/temp.linux-x86_64-3.7/src/mixer.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lSDL -lSDL_mixer -o build/lib.linux-x86_64-3.7/pygame/mixer.cpython-37m-x86_64-linux-gnu.so
    building 'pygame.mixer_music' extension
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_REENTRANT -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/include/SDL -I/usr/include/SDL -I/home/peter/.pyenv/versions/3.7.0/include/python3.7m -c src/music.c -o build/temp.linux-x86_64-3.7/src/music.o
    gcc -pthread -shared -L/home/peter/.pyenv/versions/3.7.0/lib -L/home/peter/.pyenv/versions/3.7.0/lib build/temp.linux-x86_64-3.7/src/music.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lSDL -lSDL_mixer -o build/lib.linux-x86_64-3.7/pygame/mixer_music.cpython-37m-x86_64-linux-gnu.so
    building 'pygame.scrap' extension
    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_REENTRANT -DENABLE_NEWBUF=1 -I/usr/X11R6/include -I/usr/include/SDL -I/home/peter/.pyenv/versions/3.7.0/include/python3.7m -c src/scrap.c -o build/temp.linux-x86_64-3.7/src/scrap.o
    In file included from src/scrap.c:60:0:
    src/scrap_x11.c: In function ‘pygame_scrap_get_types’:
    src/scrap_x11.c:842:35: warning: passing argument 2 of ‘PyDict_Next’ from incompatible pointer type [-Wincompatible-pointer-types]
             while (PyDict_Next (dict, &pos, &key, NULL))
                                       ^
    In file included from /home/peter/.pyenv/versions/3.7.0/include/python3.7m/Python.h:90:0,
                     f

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Update: Pygame 1.9.4 has been released and you can download and install it with pip again.


There are no official precompiled pygame packages for Python 3.7 available yet, so you have to use Python 3.6 until the new packages are released.

Windows users can already download and install a pygame wheel file from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...