python-dev 包用于什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31002091/
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-19 09:18:22  来源:igfitidea点击:

What is python-dev package used for

pythoncpython

提问by Abhisek

I recently installed lxml.

我最近安装了lxml.

Before that I had to install all the dependencies for that. So I tried to install liblxml2-dev, liblxslt1-devand python-dev(google searched for what packages are required for lxml)

在此之前,我必须为此安装所有依赖项。所以我尝试安装liblxml2-devliblxslt1-dev并且python-dev(谷歌搜索了需要什么包lxml

but even after that I could not able to install lxmlby using the command pip install lxml.

但即使在那之后,我也无法lxml使用命令 进行安装pip install lxml

However as because I am using Python 3.4.0, I thought that may be there are different version of python-dev(thought came due to facing some similar version conflict problem). So I tried to install python3-dev.

但是因为我使用的是 Python 3.4.0,所以我认为可能有不同的版本python-dev(认为​​是由于面临一些类似的版本冲突问题)。所以我尝试安装python3-dev.

Then I tried to install lxmlusing the same command said earlier and that worked!!!

然后我尝试lxml使用前面说的相同命令进行安装,并且成功了!!!

As I am a newbie in this. So I google searched for those sentences and I could able to understand the meaning of lxmland xslt. I found a linkfor python-devbut I am not still sure what it is actually doing.

因为我是这方面的新手。所以,我谷歌搜索那些句子,我能看得懂的意义lxmlxslt。我找到了一个链接python-dev但我仍然不确定它实际上在做什么。

Could anyone help :)

谁能帮忙:)

Edit 1: OS- Ubuntu

编辑 1操作系统- Ubuntu

采纳答案by Bernhard

python-dev contains the header files you need to build Python extensions. 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 Python.h file during compilation, hence those files need to be on your system such that they can be found. On Linux typically, the binary libraries and header files of packages like python are separate. Hence you can have Python installed and everything works fine but when you want to build extensions you need to install the corresponding dev package.

python-dev 包含构建 Python 扩展所需的头文件。lxml 是一个 Python C-API 扩展,当你执行pip install lxml. lxml 源#include <Python.h>代码中至少有类似的内容。编译器在编译期间查找 Python.h 文件,因此这些文件需要在您的系统上才能找到。通常在 Linux 上,二进制库和 Python 等包的头文件是分开的。因此,您可以安装 Python 并且一切正常,但是当您想要构建扩展时,您需要安装相应的开发包。

回答by Vinay Sajip

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

python-dev是包含 Python C API 头文件的包,使用它是lxml因为它包含用于高性能的 Python C 扩展。

回答by jtniehof

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

python-dev 包含编译 python 扩展模块(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 lxmland then apt-get install python3-lxml.

请注意,Debian 已经有一个用于 python 3 的 lxml 包(在http://lxml.de/installation.html 中提到);一般来说,使用打包版本是个好主意。我建议pip uninstall lxml然后apt-get install python3-lxml