简体   繁体   English

pip使用pyenv / python 3.7在ubuntu 18.04上安装pygame

[英]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. 我已经使用pyenv在ubuntu 18.04上安装了python 3.7.0,我正在尝试使用pip安装pygame。 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,
                     from src/scrap.h:27,
                     from src/scrap.c:30:
    /home/peter/.pyenv/versions/3.7.0/include/python3.7m/dictobject.h:95:17: note: expected ‘Py_ssize_t * {aka long int *}’ but argument is of type ‘int *’
     PyAPI_FUNC(int) PyDict_Next(
                     ^~~~~~~~~~~
    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/scrap.o -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-gnu -lSDL -lX11 -o build/lib.linux-x86_64-3.7/pygame/scrap.cpython-37m-x86_64-linux-gnu.so
    building 'pygame.pypm' 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 -I/usr/include -I/home/peter/.pyenv/versions/3.7.0/include/python3.7m -c src/pypm.c -o build/temp.linux-x86_64-3.7/src/pypm.o
    src/pypm.c: In function ‘__Pyx_ErrRestore’:
    src/pypm.c:4976:18: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
         if ((tstate->exc_type != NULL) & (tstate->exc_type != Py_None)) {
                      ^~~~~~~~
                      curexc_type
    src/pypm.c:4976:47: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
         if ((tstate->exc_type != NULL) & (tstate->exc_type != Py_None)) {
                                                   ^~~~~~~~
                                                   curexc_type
    src/pypm.c:4977:28: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
             tmp_type = tstate->exc_type;
                                ^~~~~~~~
                                curexc_type
    src/pypm.c:4978:29: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
             tmp_value = tstate->exc_value;
                                 ^~~~~~~~~
                                 curexc_value
    src/pypm.c:4979:26: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
             tmp_tb = tstate->exc_traceback;
                              ^~~~~~~~~~~~~
                              curexc_traceback
    src/pypm.c:4982:17: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
             tstate->exc_type = 0;
                     ^~~~~~~~
                     curexc_type
    src/pypm.c:4983:17: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
             tstate->exc_value = 0;
                     ^~~~~~~~~
                     curexc_value
    src/pypm.c:4984:17: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
             tstate->exc_traceback = 0;
                     ^~~~~~~~~~~~~
                     curexc_traceback
    At top level:
    src/pypm.c:2845:13: warning: ‘__pyx_doc_4pypm_5Input___dealloc__’ defined but not used [-Wunused-variable]
     static char __pyx_doc_4pypm_5Input___dealloc__[] = "Close midi device if still open when the instance is destroyed.";
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pypm.c:2673:13: warning: ‘__pyx_doc_4pypm_5Input___init__’ defined but not used [-Wunused-variable]
     static char __pyx_doc_4pypm_5Input___init__[] = "Instantiate MIDI input stream object.";
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pypm.c:1359:13: warning: ‘__pyx_doc_4pypm_6Output___dealloc__’ defined but not used [-Wunused-variable]
     static char __pyx_doc_4pypm_6Output___dealloc__[] = "Close midi device if still open when the instance is destroyed.";
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pypm.c:1091:13: warning: ‘__pyx_doc_4pypm_6Output___init__’ defined but not used [-Wunused-variable]
     static char __pyx_doc_4pypm_6Output___init__[] = "Instantiate MIDI output stream object.";
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    error: command 'gcc' failed with exit status 1

    ----------------------------------------
Command "/home/peter/.pyenv/versions/3.7.0/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-l6kc_seb/pygame/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-nmz05uhl/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-l6kc_seb/pygame/    

Update: Pygame 1.9.4 has been released and you can download and install it with pip again. 更新: Pygame 1.9.4已发布,您可以再次使用pip 下载并安装它。


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. 目前尚无适用于Python 3.7的官方预编译pygame软件包 ,因此您必须使用Python 3.6直到发布新软件包。

Windows users can already download and install a pygame wheel file from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame . Windows用户已经可以从以下网址 下载并安装pygame wheel文件: https : //www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 linux ubuntu 18.04 Z23EEEB4347BDD752BFC63B7EEA 上安装带有 pip 的 venv - How to install venv with pip on linux ubuntu 18.04 python 3.7 如何在 Ubuntu 18.04 上安装 python3.7 并使用 pip 创建一个 virtualenv? - How to install python3.7 and create a virtualenv with pip on Ubuntu 18.04? 为python3.7 Ubuntu 18.04安装熊猫 - Install pandas for python3.7 Ubuntu 18.04 Pip安装到python3.6但是我在Ubuntu 18.04上使用带有VS Code的python3.7 - Pip is installed to python3.6 but I'm using python3.7 with VS Code on Ubuntu 18.04 如何在 Ubuntu 18 上为 python 3.7 安装 pip? - How to Install pip for python 3.7 on Ubuntu 18? 如何在python 3.7中使用pip安装wordcloud - How to install wordcloud using pip in python 3.7 Ubuntu 18.04 和 python3.8 上的错误“pip install mysqlclient” - ERROR 'pip install mysqlclient' on Ubuntu 18.04 and python3.8 从运行python 3.6的ubuntu 18.04使用sudo pip install安装后如何删除'pafy'? - How to remove 'pafy' after installing it using sudo pip install from ubuntu 18.04 running python 3.6? 在Ubuntu 18.04中删除rabbitmq后使用pip安装python包时出现奇怪的异常 - Strange exception while using pip to install python packages after deleting rabbitmq in Ubuntu 18.04 如何在 Ubuntu 14 中使用 pip 为 python 3.7 安装软件包? - How do I install packages using pip for python 3.7 in Ubuntu 14?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM