博主因需要安装skimage,使用了命令:
pip install -U --ignore-installed scikit-image
在安装的时候发现如下一行内容:
tensorflow 1.10.0 has requirement numpy<=1.14.5,>=1.13.3, but you'll have numpy 1.16.0 which is incompatible.
意思是我现在使用的tensorflow所需的numpy版本是不超过1.14.5的,而为了安装scikit-image必须再给我整一个1.16.0的numpy,于是我运行如下代码更新了tensorflow:
pip install --upgrade tensorflow
既然你有升级需求,我偶尔也满足一下你,应该不会出问题的……
才怪!
接下来,我的pycharm瞬间多了很多红波浪线,之前能运行的代码也报废了,经过排查,发现以下两个语句会报错:
>>> import tensorflow as tf
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 47, in
import numpy as np
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 142, in
from . import core
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 57, in
from . import numerictypes as nt
File "/Library/Python/2.7/site-packages/numpy/core/numerictypes.py", line 111, in
from ._type_aliases import (
File "/Library/Python/2.7/site-packages/numpy/core/_type_aliases.py", line 63, in
_concrete_types = {v.type for k, v in _concrete_typeinfo.items()}
File "/Library/Python/2.7/site-packages/numpy/core/_type_aliases.py", line 63, in
_concrete_types = {v.type for k, v in _concrete_typeinfo.items()}
AttributeError: 'tuple' object has no attribute 'type'
>>> import tensorflow
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/tensorflow/__init__.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Library/Python/2.7/site-packages/tensorflow/python/__init__.py", line 47, in
import numpy as np
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 140, in
from . import _distributor_init
ImportError: cannot import name _distributor_init
网上查找各种解决方法……根本就没有解决方法,唯一搜到的也是他人的求助而无人回答………………
最终不得不尝试运行:
pip install tensorflow==1.10.0
成功将tensorflow更换成以前使用的版本,程序报错也消失了,送了一大口气。
这件事告诉我,