树莓派想跑个TensorFlow,结果发现各种安装包错误,各种解决,下面是一些问题的解决和解决方法。
问题三是打印Hello时输入import tensorflow as tf
执行完第一句遇到的
ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决办法一:
1.
pip3 install -U --ignore-installed wrapt enum34 simplejson netaddr
解决方法二:
针对润国说,确信自己装的包没问题,那就用
--ignore-installed <红色标注的包>
忽略掉即可
eg:sudo pip3 install <源包> --ignore-installed <红色标注的包>
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ‘/usr/local/lib/python3.5/dist-packages/wrapt-1.11.2.dist-info’
Consider using the `–user` option or check the permissions.
解决办法:
在正常的命令后面加一个 --user即可
eg:pip3 install -U --ignore-installed wrapt --user
Traceback (most recent call last):
File “/usr/bin/pip3”, line 9, in
from pip import main
ImportError: cannot import name 'main’
解决办法:
1)执行命令:sudo vi /usr/bin/pip3
(如果是pip就把路径的pip3改为pip)
2)把这部分:
from pip import main
if __name__ == '__main__':
sys.exit(main())
3)改成下面的样子:
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
RROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
解决方法:
这是由于网络问题导致的下载时给的md5校验码跟下载的不完成文件md5码对不上了。
这个没啥好方法,找个网络好点的地方,换个pip3临时国内源,多下几次就好了。
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:516: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint8 = np.dtype([(“qint8”, np.int8, 1)])
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:517: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_quint8 = np.dtype([(“quint8”, np.uint8, 1)])
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:518: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint16 = np.dtype([(“qint16”, np.int16, 1)])
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:519: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_quint16 = np.dtype([(“quint16”, np.uint16, 1)])
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:520: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.
_np_qint32 = np.dtype([(“qint32”, np.int32, 1)])
/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or ‘1type’ as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / ‘(1,)type’.等等
原因:
我装的numpy版本太高了,是numpy-1.17.3,把版本降低到1.15.0就没问题了。
解决方法:
1)先卸载1.17.3的版本:sudo pip3 uninstall numpy
2)再安装1.15.0就可以了:sudo pip3 install numpy==1.15.0
进入python,按照下面的代码做测试是否安装成功,来个Hello TensorFlow:
import tensorflow as tf #此步遇到问题参考问题三
hello = tf.constant('Hello TensorFlow!')
sess = tf.Session()
print(sess.run(hello))