本文中的环境:
树莓派4b(armv7l)
win10,与树莓派通过网线进行连接
树莓派原本已经安装了python3.9,但是在:
https://github.com/lhelontra/tensorflow-on-arm/releases
发现针对arm的wheel文件才支持到python3.7。尝试直接使用apt安装,但是发现apt无法安装相对较老的python版本(也许用apt把python3.9删除之后可以通过apt来安装python3.7,但是我没有尝试这样)
所以又参照:
Linux下安装Python3.6和第三方库
经过本地编译安装了python3.7
树莓派无法从github上下载wheel文件,所以在本地下载之后通过ftp(或者ssh)传给树莓派:
在windows与树莓派之间进行文件传输(vnc viewer不可用的情况)
之后就利用pip安装tensorflow即可:
pip install tensorflow-2.4.0-cp37-none-linux_armv7l.whl
最后跑代码时出现了:
AttributeError: module ‘tensorflow.keras.utils’ has no attribute ‘image_dataset_from_directory’
我的解决方法:
AttributeError: module ‘tensorflow.keras.utils‘ has no attribute image_dataset_from_directory——解决方法
参考:
树莓派上如何安装 tensorflow 搭建深度学习环境
https://github.com/lhelontra/tensorflow-on-arm/releases