Can';t在Raspberry Pi上的Python3.6上安装基于C的模块,如lxml和Cython

Can';t在Raspberry Pi上的Python3.6上安装基于C的模块,如lxml和Cython,python,raspberry-pi,debian,cython,raspbian,Python,Raspberry Pi,Debian,Cython,Raspbian,我从源代码构建了Python3.6,正在尝试安装lxml。尝试从pip安装时会出现以下错误: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/local/include/python3.6m -c src/lxml/etr

我从源代码构建了Python3.6,正在尝试安装lxml。尝试从pip安装时会出现以下错误:

    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/local/include/python3.6m -c src/lxml/etree.c -o build/temp.linux-armv6l-3.6/src/lxml/etree.o -w
    src/lxml/etree.c:91:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    Compile failed: command 'gcc' failed with exit status 1
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitln68cjsn.c -o tmp/xmlXPathInitln68cjsn.o
    cc tmp/xmlXPathInitln68cjsn.o -L/usr/lib -lxml2 -o a.out
    error: command 'gcc' failed with exit status 1
The following packages have unmet dependencies:
 libdbus-1-3 : Breaks: dbus (< 1.9.16-1~) but 1.6.8-1+deb7u1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
如果我试图安装Cython以从源代码编译lxml,则会出现相同的错误。我安装了libxml2dev和libxslt1dev,但是在Raspbian存储库中找不到python3.6-dev,这显然也是必需的。我在/etc/apt/sources.list中添加了以下行:

deb http://ftp.de.debian.org/debian sid main 
但是,在以后尝试安装时,我收到以下错误:

    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/libxml2 -Isrc -Isrc/lxml/includes -I/usr/local/include/python3.6m -c src/lxml/etree.c -o build/temp.linux-armv6l-3.6/src/lxml/etree.o -w
    src/lxml/etree.c:91:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    Compile failed: command 'gcc' failed with exit status 1
    cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitln68cjsn.c -o tmp/xmlXPathInitln68cjsn.o
    cc tmp/xmlXPathInitln68cjsn.o -L/usr/lib -lxml2 -o a.out
    error: command 'gcc' failed with exit status 1
The following packages have unmet dependencies:
 libdbus-1-3 : Breaks: dbus (< 1.9.16-1~) but 1.6.8-1+deb7u1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
以下包具有未满足的依赖项:
libdbus-1-3:中断:dbus(<1.9.16-1~),但要安装1.6.8-1+deb7u1
E:错误,PKGProbleResolver::解析生成的中断,这可能是由保留的包引起的。

事实上,在Debian存储库中找到的任何包(不在Raspbian one中)都会出现此错误。对此我能做些什么?

既然您是从源代码安装Python的,那么您应该已经有了头文件。还应为生成的版本使用头文件,而不是包管理器中的版本

或者

  • 将源代码目录添加到GCC使用的includes(
    GCC-I
    )或
  • 在自动包含的系统目录中安装源程序包,如
    /usr/include
    /usr/local/include

第二个选项可能是最简单的,应该可以通过标准的configure/make脚本实现。

上面输出中的第一个错误是“致命错误:Python.h:没有这样的文件或目录”。您是否安装了软件包“python3-dev”或“python3.6-dev”?这应该提供缺少的头文件。python3-dev安装了错误的版本(3.2),我在后面的文章中描述了我使用python3.6-dev的尝试。对不起,我混合了不同的信息。正如danny提到的,源代码安装程序应该已经安装了Python.h文件。不要混用“apt get install”软件包,也不要混用debian存储库。嗯,这两个选项都不能使用。1.这似乎是通过pip安装时向gcc传递参数的正确方法:
pip3.6安装lxml--global option=“-I/usr/local/include/”
。但是,这给了我一个错误
error:option-我无法识别
2。安装源程序包是什么意思?还是说从头开始重新安装Python?我尝试将Include文件夹复制到/usr/local/Include,并将其重命名为“python3.6”(因为我已经有了一个类似内容的“python3.5”文件夹),但没有成功。通过安装包,我的意思是
进行安装
。从上面的输出来看,
/usr/local/include/python3.6m
已经在includes路径中。该目录应该包含一个
Python.h
文件,否则
makeinstall
或手动将它们复制到那里。哦,我发现了问题。我把它改名为“python3.6”,而不是“python3.6m”。在解决了这个问题之后,我终于安装了lxml(并额外增加了1gb的交换空间以防止内存不足崩溃,并等待了3个小时)。谢谢