报错 : ImportError: No module named google.protobuf,这是因为找不到对应的库路径导致,到你下载的google pb编译包路径下,找到setup.py文件路径,
执行sudo python setup.py install,如果不行, 则打开管理员模式的cmd 执行: python setup.py install
执行完后可以通过执行 sudo python setup.py test 检查是否有安装成功,如果最后提示
----------------------------------------------------------------------
Ran 193 tests in 0.327s
OK
那么就是安装成功了
--------------------------------------------------------------------------------------------------------------------------------------------------------
接下来在此编译就ok了
执行python setup.py install 时可能有:This script requires setuptools version 0.6c11 to run
可从:http://download.csdn.net/download/fhqsse220/5602687下载
gzip -d setuptools-0.6c11.tar.gz
tar xf setuptools-0.6c11.tar
cd setuptools-0.6c11python setup.py install
返回如下则表示安装成功
Installed /usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
----------------------------------------------------------------------------------------------
继续报错:error: package directory 'google/protobuf/compiler' does not exist
解决办法:在google/protobuf/下创建compiler文件夹
再次在protobuf文件夹下运行:python setup.py install 。最终提示安装成功。