直接用pip安装
sudo apt-get install libhdf5-serial-dev
sudo pip3 install h5py
sudo pip3 install scipy
sudo pip3 install keras
sudo pip3 install tensorflow # 踩雷警告
检测一下安装是否成功
python3 -c "import keras,tensorflow"
报错:No module named ''tensorflow.python.eager
这是由于pip3安装的tensorflow是0.11版本,不支持安装的keras版本。
卸载掉tensorflow
sudo pip3 uninstall tensorflow*
去https://github.com/lhelontra/tensorflow-on-arm/releases 找wheel安装
注意:有些玩家可能将树莓派内核切换到64bit,uname -a 返回了aarch64,但是如果你用的是raspbian,就不能安装aarch64版本。否则在import tensorflow的时候会报错:wrong ELF class: ELFCLASS64
树莓派3/4用户请选择tensorflow-2.0.0-cp37-none-linux_armv7l.whl
cd ~/
wget https://github.com/lhelontra/tensorflow-on-arm/releases/download/v2.0.0/tensorflow-2.0.0-cp37-none-linux_armv7l.whl
sudo pip3 install tensorflow-2.0.0-cp37-none-linux_armv7l.whl
如果你像我一样使用了64bit内核,应该会报错:ERROR: tensorflow-2.0.0-cp37-none-linux_armv7l.whl is not a supported wheel on this platform.
这个解决很简单。重命名把armv7l改为aarch64即可
mv tensorflow-2.0.0-cp37-none-linux_armv7l.whl tensorflow-2.0.0-cp37-none-linux_aarch64.whl
然后再次pip3 install一下。
乾。。。又报错:ERROR: Cannot uninstall 'wrapt'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall
好像是应该卸载wrapt但是无法卸载。用ignore install模式手动装一下
sudo pip3 install -U --ignore-installed wrapt enum34 simplejson netaddr
然后继续pip3 install安装tensorflow
此时一名绝望了的网友终于看到了