No module google.protobuf

1.执行python脚本报错:

报错:No module named google.protobuf

2.于是用pip安装protobuf

#命令:失败
LisaMacBook:sudo pip install protobuf
LisaMacBook:The directory '/Users/???/Library/Caches/pip/http' 
or its parent directory is not owned by the current user 
and the cache has been disabled. Please check the permissions 
and owner of that directory. If executing pip with sudo, 
you may want sudo's -H flag

#根据提示加上-H
#命令:失败
LisaMacBook:sudo -H pip install protobuf
LisaMacBook:Could not fetch URL https://pypi.python.org/simple/pip/: 
There was a problem confirming the ssl certificate: 
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) 
- skipping

#百度解决方法
LisaMacBook:wget https://bootstrap.pypa.io/get-pip.py
#或者 curl https://bootstrap.pypa.io/get-pip.py -o ./get-pip.py

#命令:失败
LisaMacBook:python get-pip.py
LisaMacBook:Could not install packages due to an EnvironmentError: 
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-9.0.1.dist-info/DESCRIPTION.rst'
Consider using the `--user` option or check the permissions.

#加上sudo
#命令:失败
LisaMacBook:sudo python get-pip.py
LisaMacBook:The directory '/Users/Lisa/Library/Caches/pip/http' 
or its parent directory is not owned by the current user 
and the cache has been disabled. Please check the permissions 
and owner of that directory. If executing pip with sudo, 
you may want sudo's -H flag.
The directory '/Users/Lisa/Library/Caches/pip' 
or its parent directory is not owned by the current user 
and caching wheels has been disabled. 
check the permissions and owner of that directory. 
If executing pip with sudo, you may want sudo's -H flag.

#根据提示加上-H
#命令:成功
LisaMacBook:sudo -H python get-pip.py

#命令:成功
LisaMacBook:sudo -H pip install --upgrade pip

#命令:失败
LisaMacBook:sudo -H pip install protobuf
LisaMacBook:Cannot uninstall 'six'. 
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.

#命令:失败
LisaMacBook:sudo -H pip install protobuf --ignore-installed six
LisaMacBook:Could not find a version that satisfies the requirement setuptools 
(from protobuf) (from versions: )
No matching distribution found for setuptools (from protobuf)

#命令:成功
LisaMacBook:sudo -H pip install protobuf --ignore-installed six -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
Looking in indexes: http://pypi.douban.com/simple/
LisaMacBook:Successfully installed protobuf-3.6.0 setuptools-40.0.0 six-1.11.0

3.常识补充

maven: java
pip: python
compose: php docker
npm: nodejs javascript
go: go

    原文作者:Lisa
    原文地址: https://zhuanlan.zhihu.com/p/41497011
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞