文章目录
安装pip(笔者的版本为9.0)
仅使用 CPU 的版本的tensorflow
测试
异常情况
1安装tensorflow问题 owned by OS错误
2此时进行测试会出现 AttributeError: type object ‘NewBase‘ has no attribute ‘is_abstract‘
3第一个是pip的版本太低,需要升级pip:
4对于owned by OS错误:
更新six
查看pip list
再次安装tensorflow
ubuntu 14.04 + python27 环境下安装tensorflow-0.9.0
官网网址:http://www.tensorfly.cn/tfdoc/get_started/introduction.html
安装pip(笔者的版本为9.0)
$ sudo apt-get install python-pip python-dev
1
仅使用 CPU 的版本的tensorflow
$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
1
测试
正常情况下是没有问题的啦,直接进入python 环境测试:
$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> exit()
不正常的存在
没有报错就是没有安装成功了,但是…
异常情况
1安装tensorflow问题 owned by OS错误
但是笔者安装过程并没有很顺利,执行安装cpu版本的时候就出现问题咯:
changing mode of /usr/local/bin/f2py to 755
Found existing installation: wheel 0.24.0
Not uninstalling wheel at /usr/lib/python2.7/dist-packages, owned by OS
Found existing installation: six 1.5.2
Not uninstalling six at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed tensorflow numpy wheel six
Cleaning up...
2此时进行测试会出现 AttributeError: type object ‘NewBase’ has no attribute ‘is_abstract’
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 97, in <module>
from tensorflow.python.platform import test
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/test.py", line 62, in <module>
from tensorflow.python.framework import test_util
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/test_util.py", line 41, in <module>
from tensorflow.python.platform import googletest
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/googletest.py", line 32, in <module>
from tensorflow.python.platform import benchmark # pylint: disable=unused-import
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/benchmark.py", line 112, in <module>
class Benchmark(six.with_metaclass(_BenchmarkRegistrar, object)):
File "/usr/lib/python2.7/dist-packages/six.py", line 617, in with_metaclass
return meta("NewBase", bases, {})
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/benchmark.py", line 107, in __new__
if not newclass.is_abstract():
AttributeError: type object ‘NewBase‘ has no attribute ‘is_abstract‘
这个问题我是这样排查的:
3第一个是pip的版本太低,需要升级pip:
[email protected]:~$ sudo pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Installing collected packages: pip
Found existing installation: www.tygj178.com pip 1.5.4
Not uninstalling pip at www.thd540.com /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed pip
Cleaning up...
这里又出现问题了,owned by OS错误:
4对于owned by OS错误:
参考 http://www.micheng178.com .csdn.net/xuezhisdc/article/details/49588517
解决问题(参考上面的博客内容)
在/usr/local/lib/python2.7/dist-packages/下,新建mypack.pth文件,输入以下内容
新建这个文件的作用是,Python的搜索路径先搜搜/usr/local/lib/,后搜搜/usr/lib。
# 文件内容
/usr/local/lib/python2.7/dist-packages/
1
2
下载six源码
https://pypi.python.org/pypi/six or http://pypi.douban.com/simple/six
解压tar -zxvf six**
切换six**路径,并执行sudo python setup.py install
更新six
[email protected]:~$ sudo pip install six www.yigou521.com/--upgrade
1
查看pip list
~$: pip list
1
发现pip 和 six 都升级成功
再次安装tensorflow
[email protected]:~$ pip install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl
原文地址:https://www.cnblogs.com/qwangxiao/p/9849095.html