且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Ubuntu上安装python模块

更新时间:2022-02-19 02:03:29

在Ubuntu(和类似的Linux系统)上安装Python软件包有两种不错的方法:

There are two nice ways to install Python packages on Ubuntu (and similar Linux systems):

sudo apt-get install python-pygame

使用Debian/Ubuntu软件包管理器APT.这仅适用于Ubuntu附带的软件包,除非您更改APT配置,尤其是似乎没有适用于Python 3的PyGame软件包.

to use the Debian/Ubuntu package manager APT. This only works for packages that are shipped by Ubuntu, unless you change the APT configuration, and in particular there seems to be no PyGame package for Python 3.

另一种选择是使用PIP,即Python包管理器:

The other option is to use PIP, the Python package manager:

sudo apt-get install python3-pip

然后安装

sudo pip3 install pygame

要从 PyPI 获取PyGame软件包并将其安装在Python 3上,与APT相比,PIP有一些限制,但确实如此总是获取软件包的最新版本,而不是Ubuntu软件包选择的版本.

to fetch the PyGame package from PyPI and install it for Python 3. PIP has some limitations compared to APT, but it does always fetch the latest version of a package instead of the one that the Ubuntu packagers have chosen to ship.

编辑:要重复我在评论中所说的,pip3尚未在Ubuntu 12.04中使用.仍然可以使用

EDIT: to repeat what I said in the comment, pip3 isn't in Ubuntu 12.04 yet. It can still be installed with

sudo apt-get install python3-setuptools
sudo easy_install3 pip
sudo apt-get purge python-pip

此后,pip是PIP的Python 3版本,而不是pip3.最后一条命令只是为了安全;可能安装了/usr/bin/pip的Python 2 PIP.

After this, pip is the Python 3 version of PIP, instead of pip3. The last command is just for safety; there might be a Python 2 PIP installed as /usr/bin/pip.