系统教程
您现在的位置是:首页>服务器系统>Linux系统内容

安装Python扩展提示Configure error: Python headers not found

时间:2018-05-11 出处:未知复制分享人气(次) 【

在配置ns3的开发环境时,需要安装Python系列的扩展包,这些扩展都是基于Python2.7.x版本的,但是Manjaro的默认Python版本是3.x,所以在安装2.7.x版本的扩展时,可能会遇到下面这样一个错误:
configure checking for python version... 3.6
configure checking for python platform... linux
configure checking for python script directory... ${prefix}/lib/python3.6/site-packages
configure checking for python extension module directory... ${exec_prefix}/lib/python3.6/site-packages
configure checking for headers required to compile python extensions...   File"", line 1
configure     import sys; print sys.prefix
configure                         ^
configure SyntaxError: invalid syntax
configure   File"", line 1
configure     import sys; print sys.exec_prefix
configure                         ^
configure SyntaxError: invalid syntax
configure not found
configure configure: error: Python headers not found
 
我们来看一下错误原因啊,SyntaxError,语法错误,报错误的语句是:
import sys; print sys.exec_prefix
 
为什么会报语法错误呢?这在Python2.7.x中完全没有问题啊,可是看上面我们编译时系统默认的Python版本,是3.6,在Python3.x中,print后面是要加括号的,所以,如果我们要安装Python2.x的扩展,那么需要改一下默认的Python版本,切换到root用户,用:
ls -l /usr/bin/python*
 
命令查看一下,通常/usr/bin/python应该只是一个符号链接指向Python3或者Python2,如果是指向Python3,那么我们需要先删除原来的符号链接,然后再新建一个指向Python2的符号链接:
rm /usr/bin/python
ln -s /usr/bin/python2.7 /usr/bin/python
 
这就为Python2.7创建了一个符号链接,是不需要重启的,做完之后重新开始编译工作就可以了。
    最新资讯
    热门内容
    小米移动电源能为iPad mini充几次电