在Raspbian Stretch 2019-11-13上安装TensorFlow存在Python兼容性问题

时间:2019-03-03 17:02:13

标签: tensorflow python-3.5 raspbian

使用新的SD卡和Raspbian版本Stretch 2018-11-13:

sudo apt install -y python3-pip python3-dev python-virtualenv
virtualenv -p python3.5 --system-site-packages myenv
source myenv/bin/activate
pip3 install --upgrade tensorflow
$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
/home/pi/myenv/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
  return f(*args, **kwds)
/home/pi/myenv/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
  return f(*args, **kwds)
>>> 

1 个答案:

答案 0 :(得分:0)

检查您的Python环境是否已配置(需要Python 3.4、3.5或3.6):

python3 --version
pip3 --version
virtualenv --version

如有必要,安装以下软件包:

sudo apt update  
sudo apt install python3 python3-pip

Raspbian操作系统的TensorFlow要求:

sudo apt update
sudo apt install python3-dev python3-pip  
sudo apt install libatlas-base-dev        # required for numpy  
sudo pip3 install --upgrade pip  
sudo pip3 install --upgrade virtualenv    # system-wide install  

通过选择Python解释器并创建一个myenv目录来保存它来创建一个新的虚拟环境:

virtualenv --system-site-packages -p python3 myenv

正如您在问题中提到的那样,Debian Stretch中的python3软件包版本为3.5。

安装TensorFlow(系统安装):

sudo pip3 install --user --upgrade tensorflow 

验证安装:

python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"

IMG: 成功:现在已安装TensorFlow。阅读tutorials开始使用。