Python-dev 包的用途是什么

我最近安装了 lxml

在此之前,我必须为此安装所有依赖项。 所以我尝试安装 liblxml2-devliblxslt1-devpython-dev (google 搜索 lxml需要什么软件包) 但即使在那之后,我也不能使用这个命令安装 lxml pip install lxml.

然而,由于我使用的是 Python 3.4.0,我认为可能有不同版本的 python-dev(这种想法是由于面临一些类似的版本冲突问题而产生的)。所以我尝试安装 python3-dev

然后,我试图安装 lxml使用相同的命令说前面和工作! ! !

我用谷歌搜索了这些句子 我能够理解 lxmlxslt的含义。我发现了一个 链接python-dev,但我仍然不知道它实际上是做什么。

OS-Ubuntu 操作系统

131407 次浏览

python-dev

python-dev contains the header files you need to build Python extensions.

lxml

lxml is a Python C-API extension that is compiled when you do pip install lxml. The lxml sources have at least something like #include <Python.h> in the code. The compiler looks for the header file Python.h during compilation, hence those header files need to be on your system such that they can be found.

-dev packages on Linux

On Linux typically, the binary libraries and header files of packages like Python are separate. Hence you can have Python (e.g. package python) installed and everything works fine. But when you want to build extensions you need to install the corresponding -dev package.

python-dev is the package that contains the header files for the Python C API, which is used by lxml because it includes Python C extensions for high performance.

python-dev contains everything needed to compile python extension modules (https://docs.python.org/2/extending/extending.html).

Note that Debian already has an lxml package for python 3 (mentioned at http://lxml.de/installation.html); in general it's a good idea to use the packaged version. I'd suggest pip uninstall lxml and then apt-get install python3-lxml.