With a new SD card and Raspbian version 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)
>>>
Check if your Python environment is already configured (requires Python 3.4, 3.5, or 3.6):
python3 --version
pip3 --version
virtualenv --version
Install these packages if necessary:
sudo apt update
sudo apt install python3 python3-pip
TensorFlow requirements for the Raspbian operating system:
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
Create a new virtual environment by choosing a Python interpreter and making a myenv
directory to hold it:
virtualenv --system-site-packages -p python3 myenv
As you mentioned in your question, the python3 package version in Debian Stretch is 3.5.
Install TensorFlow (system install):
sudo pip3 install --user --upgrade tensorflow
Verify the install:
python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
Success: TensorFlow is now installed. Read the tutorials to get started.