python及第三方库交叉编译( 四 )


python及第三方库交叉编译

文章插图
12、交叉编译第三方库成为.whl格式的安装包:./pip3 wheel --wheel-dir /home/target_lib -r requirements.txt
13、验证:cd /home/target_lib
python及第三方库交叉编译

文章插图
14、注意,这里我们使用crossenv交叉编译后的numpy第三方库的后缀是linux_arm,而我们的目标板子是armv7l的,所以这里我们要手动的将
numpy-1.18.5-cp35-cp35m-linux_arm.whl改为numpy-1.18.5-cp35-cp35m-linux_armv7l.whl 。不然会报错 。这个坑,一直坑了我一个月的时间,尝试了很多方法,不知道是编译链的问题,还是编译过程的问题 。将交叉编译后的numpy的.whl文件移植到目标板子的中,总是报错,突然灵光一闪,就手动改个名字,居然可以了,这坑简直是巨坑,坑了一个月的时间 。
十六、移植到目标板子将编译好的python-target打包 和 numpy-1.18.5-cp35-cp35m-linux_arm.whl(先不改名,移植到目标板子上在改名)移植到目标板子上
1、压缩python-target: tar cvf python-target.tar python-target
2、通过ftp工具,将python-target.tar和numpy-1.18.5-cp35-cp35m-linux_arm.whl ,移植到目标板子的/home下
python及第三方库交叉编译

文章插图
   3、解压python-target: tar xvf python-target.tar
4、cd /home/python-target/bin
5、验证在目标板子上运行python3
python及第三方库交叉编译

文章插图
6、验证交叉编译的第三方
1、先下载pip: curl https://bootstrap.pypa.io/pip/3.5/get-pip.py -o get-pip.py -k
2、安装pip: ./python3 get-pip.py
3、配置pip源
a、mkdir ~/.pip
b、vi ~/.pip/pip.conf
c、添加如下代码
[global]index-url = https://pypi.tuna.tsinghua.edu.cn/simple trusted-host = pypi.tuna.tsinghua.edu.cn4、验证pip
python及第三方库交叉编译

文章插图
5、通过pip安装未改名的numpy第三方库:这是会报错:numpy-1.18.5-cp35-cp35m-linux_arm.whl is not a supported wheel on this platform.
python及第三方库交叉编译

文章插图
6、改名:  mv /home/numpy-1.18.5-cp35-cp35m-linux_arm.whl /home/numpy-1.18.5-cp35-cp35m-linux_armv7l.whl
7、重新安装验证:
python及第三方库交叉编译

文章插图
到此python3及python需要的第三方库,类似numpy这样需要交叉编译的第三方库就完成了!其中其他库不一定都是完全一样的,但是大致流程是一样的可以参考借鉴 。

【python及第三方库交叉编译】

经验总结扩展阅读