Http://www.pygame.org/wiki/CompileUbuntu#Python%203.x%20into%20virtual%20environment
Install dependencies First:
?sudoApt-getInstallMercurial Python3-dev Python3-numpy libav-Tools> Libsdl-image1.2-dev Libsdl-mixer1.2-dev LIBSDL-TTF2.0-dev libsmpeg-Dev> LIBSDL1.2-dev Libportmidi-dev Libswscale-dev Libavformat-dev libavcodec-Dev is reading the package list ... Completing the dependency tree that is analyzing the package is reading state information ... Completion of mercurial is already the latest version. Python3-Dev is already the latest version. The following additional packages will be installed: Libasound2-dev libavahi-client-dev libavahi-common-dev libavdevice55 libavfilter5 libavresample-dev libavutil-dev Libcaca-dev libdbus-1-dev libdirectfb-Dev LIBDIRECTFB-extra libelfg0 libflac-dev libfluidsynth1 libfreetype6-dev libgl1-mesa-dev libglib2.0-bin Libglib2.0-dev Libglu1-mesa-dev Libjbig-dev libjpeg-Dev libjpeg62-turbo-dev liblzma-dev libmad0-dev libmikmod-config libmikmod-dev libmikmod3 libogg-dev libopenal-data libopenal1 Libopencv-core2.4Libopencv-imgproc2.4Libpcre3-dev libpcrecpp0 libpng12-dev libportmidi0 libpulse-dev libpulse-mainloop-glib0 libsdl-mixer1.2LIBSDL-TTF2.0-0libslang2-Dev libsmpeg0 libtbb2 libtiff5-dev libtiffxx5 Libvorbis-dev Libwebp-dev libx11-xcb-dev libxcb-dri2-0-dev Libxcb-dri3-dev Libxcb-glx0-dev Libxcb-present-dev libxcb-randr0-Dev LIBXCB-render0-dev Libxcb-shape0-dev libxcb-Sync-dev libxcb-xfixes0-dev libxdamage-dev libxext-dev libxfixes-dev libxshmfence-dev libxxf86vm-Dev Musescore-soundfont-gmPkg-configX11proto-damage-dev x11proto-dri2-dev X11proto-fixes-dev X11proto-gl-dev x11proto-xext-dev x11proto-xf86vidmode-Dev Recommended packages for installation: Libasound2-doc Frei0r-plugins libdc1394- A-dev libgsm1-dev libraw1394-dev libschroedinger-dev libspeex-dev libtheora-dev libglib2.0-doc liblzma-Doc Libportaudio2 Libxext-doc fluidsynth timidity Gfortran python-numpy-doc python3-nose python3-numpy-DBG the following "new" packages will be installed: Libasound2-dev libav-tools libavahi-client-dev libavahi-common-dev libavcodec-dev libavdevice55 libavfilter5 Libavformat-dev Libavresample-dev libavutil-Dev Libcaca-dev libdbus-1-dev libdirectfb-dev Libdirectfb-extra libelfg0 libflac-dev libfluidsynth1 libfreetype6-dev libgl1-mesa-dev libglib2.0-bin Libglib2.0-Dev LIBGLU1-mesa-dev libjbig-dev libjpeg-dev libjpeg62-turbo-dev liblzma-dev libmad0-dev libmikmod-config Libmikmod-dev Libmikmod3 Libogg-dev libopenal-Data Libopenal1 Libopencv-core2.4Libopencv-imgproc2.4Libpcre3-dev libpcrecpp0 libpng12-dev libportmidi-dev libportmidi0 libpulse-dev libpulse-mainloop-glib0 libsdl-image1.2-dev Libsdl-mixer1.2Libsdl-mixer1.2-dev LIBSDL-TTF2.0-0LIBSDL-TTF2.0-dev LIBSDL1.2-dev Libslang2-dev Libsmpeg-dev libsmpeg0 libswscale-Dev libtbb2 libtiff5-dev libtiffxx5 Libvorbis-dev Libwebp-dev libx11-xcb-dev libxcb-dri2-0-dev Libxcb-dri3-dev Libxcb-glx0-dev Libxcb-present-dev libxcb-randr0-Dev LIBXCB-render0-dev Libxcb-shape0-dev libxcb-Sync-dev libxcb-xfixes0-dev libxdamage-dev libxext-dev libxfixes-dev libxshmfence-dev libxxf86vm-Dev Musescore-soundfont-gmPkg-configPython3-numpy x11proto-damage-dev X11proto-dri2-dev X11proto-fixes-dev x11proto-gl-dev x11proto-xext-Dev X11proto-xf86vidmode-Dev has upgraded0A new package, a newly installedBayiA package to uninstall0Packages that have1packages have not been upgraded. Need to download24.9MB/27.4MB of software packages. will be consumed after decompression86.9MB of extra space. Do you want to continue? [Y/n]
After installation in the virtual environment:
(kivy) ~/pythonvenv echo hg+http://bitbucket.org/pygame/pygame >> requirements.txt Install -R requirements.txt (kivyinstall)~/pythonvenv Install -R Requirements.txtdownloading/unpacking hg+http://Bitbucket.org/pygame/pygame (from-r Requirements.txt (line 1)) cloning HG http://bitbucket.org/pygame/pygame to/tmp/ Pip-evluwa4c-buildsuccessfully installed pygamecleaning up ...
Try it:
? Python ~/test/kivy/helloworld.py [INFO] [Logger] Record loginch/home/z/.kivy/logs/kivy_15- A-13_6.txt[info] [Kivy] v1.9.0[INFO] [Python] v3.4.2(Default, OCT8 the,Ten: $: -) [GCC4.9.1][info] [Factory]173symbols Loaded[info] [Image] Providers:img_tex, Img_dds, Img_gif, Img_pygame (Img_pil, Img_ffpyplayer Igno RED) [INFO] [Text] provider:pygame[info] [Window] Provider:pygame (['Window_egl_rpi'] ignored)Libgl error:no matching fbconfigs or visuals Foundlibgl error:failed to load driver:swrastX Erro R of failed Request:badvalue (integer parameter out of range foroperation) Major opcode of Failed request:155(GLX) Minor opcode of failed request:3(x_glxcreatecontext) ValueinchFailed Request:0x0Serial Number of failed request: -Current serial numberinchOutput stream: the
This is a graphics driver issue and reinstall the video driver. See http://www.cnblogs.com/ibgo/p/5043613.html
Installing Pygame in a virtual environment