安装TensorFlow时提示protobuf requires Python ‘>=3.7‘ but the running Python is 3.6.5

安装TensorFlow时提示protobuf requires Python ‘>=3.7‘ but the running Python is 3.6.5

安装TensorFlow时提示protobuf requires Python ‘>=3.7‘ but the running Python is 3.6.5的问题,通过字面的意思就是protobuf运行依赖python的版本是3.7,而当前运行的版本低于3.7,所以出现错误,这时候很多人都会认为需要升级python的版本,如果这样做就真的是被这个错误误导了,其实出现这个问题的关键是pip的问题,需要更新pip。


解决方案:

执行pip更新命令:

python3 -m pip install --upgrade pip

接着再执行命令:

pip install tensorflow==1.14.0

重新安装TensorFlow,看是否还会出现错误提示,可能有的人还会遇到:

AttributeError: 'NoneType' object has no attribute 'bytes'

的问题,那么就执行如下命令:

python -m pip install -U --force-reinstall pip

再次执行安装TensorFlow,问题基本能够得到解决。