在 Raspbian Stretch 上安装 TensorFlow 2019-11-13 有 Python 兼容性问题 [英] Installing TensorFlow on Raspbian Stretch 2019-11-13 has Python compatibility problems

查看:43
本文介绍了在 Raspbian Stretch 上安装 TensorFlow 2019-11-13 有 Python 兼容性问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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)
>>> 

推荐答案

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

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

Raspbian 操作系统的 TensorFlow 要求:

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 python3 -m pip install --upgrade pip  
sudo python3 -m pip install --upgrade virtualenv    # system-wide install  

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

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

正如您在问题中提到的,Debian Stretch 中的 python3 软件包版本是 3.5.

As you mentioned in your question, the python3 package version in Debian Stretch is 3.5.

安装 TensorFlow(系统安装):

Install TensorFlow (system install):

sudo python3 -m pip install --user --upgrade tensorflow 

验证安装:

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

成功: TensorFlow 现已安装.阅读教程以开始使用.

Success: TensorFlow is now installed. Read the tutorials to get started.

这篇关于在 Raspbian Stretch 上安装 TensorFlow 2019-11-13 有 Python 兼容性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆