在 Ubuntu 上安装 python 模块 [英] Installing python modules on Ubuntu

查看:58
本文介绍了在 Ubuntu 上安装 python 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 Ubuntu Linux 12.04 上为 python 安装一些模块.我想要 pygame 和 livewires,但我不知道如何安装它们.

I need to install some modules for python on Ubuntu Linux 12.04. I want pygame and livewires but I'm not sure how to install them.

我有 livewires 的 py 文件,该文件经过特别编辑(来自我正在阅读的一本书),我想安装它,但我不确定如何安装,我也想安装 pygame.

I have the py file for livewires, which has been specially edited (from a book I'm reading) and I want to install it but I'm not sure how to, I also want to install pygame.

推荐答案

在 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.

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

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.最后一条命令只是为了安全;可能有一个 Python 2 PIP 安装为 /usr/bin/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.

这篇关于在 Ubuntu 上安装 python 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆