问题
欲使用命令:pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensor
flow-0.5.0-cp27-none-linux_x86_64.whl安装tensorflow时,在安装pip的步骤中,使用命令:
sudo apt-get install python-pip安装pip出现如下错误:
The following packages have unmet dependencies:
python-pip : Depends: python-pip-whl (= 1.5.4-1ubuntu3) but it is not going to be installed
Recommends: python-dev-all (>= 2.6) but it is not installable
E: Unable to correct problems,you have held broken packages.
解决方法
1、 sudo apt-get update
2、sudo apt-get upgrade
3、sudo apt-get install python-setuptools python-dev build-essential
4、sudo easy_install pip
5、最后使用命令:pip install https://storage.googleapis.com/tensorflow/linux/cpu/
tensorflow-0.5.0-cp27-none-linux_x86_64.whl即可安装成功
测试代码及结果
打开一个 python 终端:
$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello,TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello,TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>