简体   繁体   English

安装pygame ubuntu时遇到问题

[英]Having trouble installing pygame ubuntu

I'm having a lot of trouble installing pygame.我在安装 pygame 时遇到了很多麻烦。 I'm running ubuntu.我正在运行 ubuntu。 I'm trying to install it with 'pip install pygame' but I keep getting an error message:我正在尝试使用“pip install pygame”安装它,但我不断收到错误消息:

     Unable to run "sdl-config". Please make sure a development version of SDL is installed.

I've tried downloading the source from the pygame website but still its not working i just get the same error when i try and run setup.py.我已经尝试从 pygame 网站下载源代码,但仍然无法正常工作,我只是在尝试运行 setup.py 时遇到相同的错误。

Any Ideas?有什么想法吗? Thanks in advance.提前致谢。

The easiest way to install Pygame on Ubuntu is through apt .在 Ubuntu 上安装 Pygame 的最简单方法是通过apt Just run sudo apt-get install python-pygame , and it will handle all the native dependencies for you.只需运行sudo apt-get install python-pygame ,它将为您处理所有本机依赖项。 pip is better for pure-python dependencies or if you have to use it (eg, in a virtualenv). pip更适合纯 python 依赖项,或者如果您必须使用它(例如,在 virtualenv 中)。

If u got error like 404 Not Found when run如果你在运行时遇到类似 404 Not Found 的错误
sudo apt-get install python-pygame

Then this link can help you那么这个链接可以帮助你
https://community.webfaction.com/questions/315/how-do-i-install-pygame https://community.webfaction.com/questions/315/how-do-i-install-pygame

Here is the solution that worked for me:这是对我有用的解决方案:

sudo apt-get build-dep python-pygame
sudo apt-get install python-dev
sudo apt-get install libv4l-dev
cd /usr/include/linux
sudo ln -s ../libv4l1-videodev.h videodev.h

and finally run the pip command (can be done through virtualenv or conda):最后运行 pip 命令(可以通过 virtualenv 或 conda 完成):

pip install 'Pygame == 1.9.1release' --allow-external Pygame --allow-unverified Pygame

In pycharm specifying a dev version (in my case 2.0.0.dev8) fixed that problem for me.pycharm 中指定一个开发版本(在我的例子中是 2.0.0.dev8)为我解决了这个问题。
Here's the after:这是之后:

在此处输入图片说明

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM