我需要在Ubuntu Linux 12.04上为Python安装一些模块。我想要pygame和livewires,但是我不确定如何安装它们。
我有livewires的py文件,这是从我正在阅读的书中特别编辑过的,我想要安装它,但我不确定如何操作,我还想安装pygame。
我需要在Ubuntu Linux 12.04上为Python安装一些模块。我想要pygame和livewires,但是我不确定如何安装它们。
我有livewires的py文件,这是从我正在阅读的书中特别编辑过的,我想要安装它,但我不确定如何操作,我还想安装pygame。
在Ubuntu(和类似的Linux系统)上安装Python包有两种不错的方法:
sudo apt-get install python-pygame
使用Debian/Ubuntu包管理器APT。这仅对由Ubuntu提供的软件包有效,除非您更改APT配置,特别是似乎没有适用于Python 3的PyGame包。
另一个选择是使用Python包管理器PIP:
sudo apt-get install python3-pip
安装它,然后
sudo pip3 install pygame
pip3
在Ubuntu 12.04中尚未出现。仍然可以使用以下方式进行安装。sudo apt-get install python3-setuptools
sudo easy_install3 pip
sudo apt-get purge python-pip
接下来,pip
是 Python 3 版本的 PIP,而不是 pip3
。最后一条命令只是为了安全起见;有可能已经安装了 Python 2 的 PIP,并且位于 /usr/bin/pip
。
apt-get install python-pip
pip install pygame
python setup.py build
python setup.py install
2 - 使用pip。Pip非常简单。在控制台中,您需要输入以下命令:
pip install package_name
pip install libraryname
对于Python 3.5,请使用
pip3 install libraryname
有时候,在Linux安装软件包的过程中,由于我不知道的原因,会阻止对Python的访问,所以也可以尝试以下方法:
sudo apt install python-libraryname
并且适用于Python 3.5版本
sudo apt install python3-libraryname
!pip install libraryname
curl -O http://python-distribute.org/distribute_setup.py
sudo python distribute_setup.py
sudo easy_install pygame
import
,除非您对Python设置进行了疯狂的更改。 - Fred Fooapt
,请参见如何查找提供文件的软件包?。 - tripleee