在 GNU/Linux 中安装 python 模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3759810/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:14:21  来源:igfitidea点击:

Installing python modules in GNU/Linux

pythonlinuxmodule

提问by hidroto

installing python modules in GNU/Linux. Are there any good PDFs on installing modules? I would like to install some of these Python: 50 modules for all needs. I tried PIL http://effbot.org/downloads/Imaging-1.1.7.tar.gzbut it did not work.

在 GNU/Linux 中安装 python 模块。有没有关于安装模块的好的 PDF 文件?我想安装其中一些Python: 50 modules for all needs。我试过 PIL http://effbot.org/downloads/Imaging-1.1.7.ta​​r.gz但没有用。

PS: what does community wiki mean?

PS:社区维基是什么意思?

回答by mgiuca

On a Debian or Ubuntu system, the easiest way to install Python packages, if available, is apt-get. The easy_install system contains more Python packages, but the apt-get packages are specifically tuned for your system.

在 Debian 或 Ubuntu 系统上,安装 Python 包的最简单方法(如果可用)是 apt-get。easy_install 系统包含更多 Python 包,但 apt-get 包专门针对您的系统进行了调整。

They always start with 'python-'.

它们总是以“python-”开头。

For example,

例如,

sudo apt-get install python-imaging

回答by Keith

Most of those are probably already available as packages in your Linux distribution. You didn't mention which one you used. Typically, "apt-get" or "yum" would cover most current distributions. Read the man pages for those tools, and use the search features to find packages containing the name "python", or the names of the packages in the list.

其中大部分可能已经在您的 Linux 发行版中作为软件包提供。你没有提到你用的是哪一个。通常,“apt-get”或“yum”将涵盖大多数当前发行版。阅读这些工具的手册页,并使用搜索功能查找包含名称“python”或列表中的包名称的包。

If the one you want is not there, install "setuptools", then use "easy-install" to fetch them from the Python package index (PyPI).

如果您想要的那个不在那里,请安装“setuptools”,然后使用“easy-install”从 Python 包索引 (PyPI) 中获取它们。

Only if the above fail you should build from source. That will require a build environment, typically involving installing "dev" or "development" packages, e.g "python-dev" on some distros. You may also need some other library -dev packages.

只有当上述失败时,您才应该从源代码构建。这将需要一个构建环境,通常涉及安装“dev”或“development”包,例如在某些发行版上安装“python-dev”。您可能还需要一些其他库 -dev 包。

Once you have the required development packages installed, the distutils (or setuptools) standard method to build from source should be used.

一旦安装了所需的开发包,就应该使用 distutils(或 setuptools)标准方法从源代码构建。

The command

命令

$ python setup.py build

$ python setup.py 构建

should work. If it doesn't you may need more -dev packages. Check the error messages.

应该管用。如果不是,您可能需要更多 -dev 包。检查错误消息。

If it does build, then use "sudo python setup.py install" to install it.

如果它确实构建,则使用“sudo python setup.py install”来安装它。

Without more info, it's hard to give a more specific answer.

没有更多信息,很难给出更具体的答案。