linux 下编译python


1. 下载Python源代码

到 https://www.python.org/ftp/python/ 上下载与电脑对应版本的Python

2. 编译

执行下列命令编译安装
--prefix设置安装的位置,便于管理

./configure --host=arm-linux --build=arm-linux-gnueabihf ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no --disable-ipv6 --prefix=/home/apps/python3

host与本机的arm库路径名称一致

2.1. 编译中遇到的错误

  1. 遇到错误configure: error: readelf for the host is required for cross builds
    看样子是缺少readelf这个文件
    在arm-gcc的bin目录下发现一个arm-linux-gnueabihf-readelf,在此目录执行
ln -s arm-linux-gnueabihf-readelf arm-linux-readelf

 

  1. 遇到错误Fatal: You must get working getaddrinfo() function. or you can specify "--disable-ipv6".
    因为用不到IPv6,所以在configure后面加上--disable-ipv6

  2. configure: error: set ac_cv_file__dev_ptmx to yes/no in your CONFIG_SITE file when cross compiling
    在configure后面加上ac_cv_file__dev_ptmx=no即可

  3. configure: error: set ac_cv_file__dev_ptc to yes/no in your CONFIG_SITE file when cross compiling
    同样加上ac_cv_file__dev_ptc=no

  4. configure: error: cannot run C compiled programs. If you meant to cross compile, use '--host'.
    交叉编译需要设置--host--build两个参数



作者:uenigma
链接:https://www.jianshu.com/p/7346cc4e41ac
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
 
当在arm机器上,使用python调用出现 Illegal instruction(core dumped)时,将numpy从1.19.5降级至1.19.4,可能可以解决问题


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM