我用过
./configure --prefix=$HOME
make
make install
安装sdl2, 之后我尝试通过
安装pygamecd ../pygame-1.9.1release/
python setup.py install
但是我收到了一个错误:
linuxnx:~/python/library/pygame-1.9.1release> python setup.py install
WARNING, No "Setup" File Exists, Running "config.py"
Using UNIX configuration...
Hunting dependencies...
sh: sdl-config: command not found
WARNING: "sdl-config" failed!
sh: smpeg-config: command not found
WARNING: "smpeg-config" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
答案 0 :(得分:31)
我搜索了很长时间,因为我需要Eric Matthes编写的Python Crash Course软件包,但找不到有助于运行的答案
pip install pygame
没有错误,最终找到了一种对我有用的解决方案
sudo apt-get install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python-numpy subversion libportmidi-dev ffmpeg libswscale-dev libavformat-dev libavcodec-dev libfreetype6-dev
答案 1 :(得分:11)
我看到这个线程已经存在很长时间了,但是我认为最好把它留在这里,以防它对某人有所帮助。 我在a website上找到了以下几行可能会有所帮助:
目前,2020年5月1日,您无法在以下位置安装pygame库: python 3.8 with pip install pygame,但是您可以使用 它们的特定版本,仍供开发人员使用。您可以安装Python 3.8 在使用此版本的命令行中:pip install pygame == 2.0.0.dev6 最新版本:pip install pygame == 2.0.0.dev10
我不知道您是否使用python3,但是除了sdl之外,它还会给我带来更多错误 以及freetype-config ...在使用“ python3 -m pip install pygame”之前。
:~$ python3 -m pip install pygame==2.0.0.dev10
Collecting pygame==2.0.0.dev10
Downloading pygame-2.0.0.dev10-cp38-cp38-manylinux1_x86_64.whl (14.3 MB)
|████████████████████████████████| 14.3 MB 130 kB/s
Installing collected packages: pygame
Successfully installed pygame-2.0.0.dev10
所有编程时间都不错!! =)
答案 2 :(得分:2)
在终端试试这个,它应该安装sdl 1.2 #制作一个临时目录,我们可以下载和构建东西
mkdir tmp
cd tmp
# download and install SDL
wget http://www.libsdl.org/release/SDL-1.2.14.tar.gz
tar -xzvf SDL-1.2.14.tar.gz
cd SDL-1.2.14
./configure
sudo make all
答案 3 :(得分:1)
PyGame-1.9.1创建于2009年,因此它仍然使用旧的SDL 1.2而不是新的SDL2。
PySDL2使用SDL2
答案 4 :(得分:1)
在我阅读上面的最佳答案之后,
我安装了python-dev,libsdl-image1.2-dev。
然后我得到了
Hunting dependencies...
WARNING: "pkg-config freetype2" failed!
WARNING: "freetype-config" failed!
SDL : found 1.2.15
FONT : not found
IMAGE : found
MIXER : not found
PNG : found
JPEG : found
SCRAP : found
PORTMIDI: not found
PORTTIME: not found
FREETYPE: not found
Missing dependencies
所以我刚安装了这些,就可以了。
sudo apt install python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libportmidi-dev libfreetype6-dev
答案 5 :(得分:0)
此错误在Pygame-2.0.0.dev12中再次出现
对我来说,解决方案是:
sudo apt-get install libsdl2-dev
然后我得到了
Hunting dependencies...
SDL : found 2.0.9
FONT : not found
IMAGE : not found
MIXER : not found
PNG : found
JPEG : found
SCRAP : found
PORTMIDI: found
PORTTIME: found
FREETYPE: found 22.1.16
所以我在下面运行了这个命令:
sudo apt-get install libsdl2-mixer-dev libsdl2-image-dev libsdl2-ttf-dev
弥补缺少的依赖项