python-dev包用于什么 [英] What is python-dev package used for
问题描述
我最近安装了 lxml
。
在此之前,我必须为此安装所有依赖项。
所以我尝试安装 liblxml2-dev
, liblxslt1-dev
和 python -dev
(Google搜索了 lxml
所需的软件包)
Before that I had to install all the dependencies for that.
So I tried to install liblxml2-dev
, liblxslt1-dev
and python-dev
(google searched for what packages are required for lxml
)
但是即使那样,我也无法使用命令
pip install lxml
安装 lxml
but even after that I could not able to install lxml
by using the command
pip install lxml
.
但是,由于我使用的是Python 3.4.0,我认为可能是 python-dev $ c的其他版本$ c>(之所以想到此是因为遇到了一些类似的版本冲突问题)。所以我尝试安装
python3-dev
。
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
.
然后我尝试安装 lxml
使用前面说过的相同命令,它确实起作用!!!
Then I tried to install lxml
using the same command said earlier and that worked!!!
因为我是新手。因此,我在google中搜索了这些句子
,我就能理解 lxml
和 xslt
的含义。我找到了 python-dev $ c $的链接 c>但我仍然不确定它的实际作用。
As I am a newbie in this. So I google searched for those sentences
and I could able to understand the meaning of lxml
and xslt
. I found a link for python-dev
but I am not still sure what it is actually doing.
有人可以帮忙吗:)
编辑1 : OS -Ubuntu
推荐答案
python-dev包含标头构建Python扩展所需的文件。 lxml是Python C-API扩展,在您执行 pip install lxml
时会编译。 lxml源代码中至少有类似 #include< Python.h>
之类的东西。编译器会在编译过程中查找Python.h文件,因此这些文件必须位于您的系统上才能被找到。
通常在Linux上,像python这样的软件包的二进制库和头文件是分开的。因此,您可以安装Python,并且一切正常,但是当您要构建扩展时,需要安装相应的dev软件包。
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包用于什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!