无法在 Python 3.6 Raspberry Pi 上安装基于 C 的模块,如 lxml 和 Cython
Can't install C-based modules like lxml and Cython on Python 3.6 on Raspberry Pi
我从源代码构建了 Python 3.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
如果我尝试安装 Cython 以从源代码编译 lxml,则会出现相同的错误。我安装了 libxml2-dev 和 libxslt1-dev,但是在 Raspbian 存储库中找不到显然也需要的 python3.6-dev。我将以下行添加到 /etc/apt/sources.list:
deb http://ftp.de.debian.org/debian sid main
但是之后尝试安装时,我收到以下错误:
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.
事实上,在 Raspbian 之外的 Debian 存储库中找到的任何软件包都会引发此错误。我该怎么办?
由于您从源代码安装了 Python,您应该已经有了头文件。还应该为您构建的版本使用头文件,而不是包管理器中的版本。
两者都
- 将源代码目录添加到 GCC 使用的包含 (
gcc -I<dir>
) 或
- 在自动包含的系统目录中安装源包,如
/usr/include
或 /usr/local/include
第二个选项可能是最简单的,应该可以从标准 configure/make 脚本中获得。
我从源代码构建了 Python 3.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
如果我尝试安装 Cython 以从源代码编译 lxml,则会出现相同的错误。我安装了 libxml2-dev 和 libxslt1-dev,但是在 Raspbian 存储库中找不到显然也需要的 python3.6-dev。我将以下行添加到 /etc/apt/sources.list:
deb http://ftp.de.debian.org/debian sid main
但是之后尝试安装时,我收到以下错误:
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.
事实上,在 Raspbian 之外的 Debian 存储库中找到的任何软件包都会引发此错误。我该怎么办?
由于您从源代码安装了 Python,您应该已经有了头文件。还应该为您构建的版本使用头文件,而不是包管理器中的版本。
两者都
- 将源代码目录添加到 GCC 使用的包含 (
gcc -I<dir>
) 或 - 在自动包含的系统目录中安装源包,如
/usr/include
或/usr/local/include
第二个选项可能是最简单的,应该可以从标准 configure/make 脚本中获得。