homebrew-grpc icon indicating copy to clipboard operation
homebrew-grpc copied to clipboard

grpc python installed with virtualenv, code complains no google.protobuf found on Mac OS X

Open awakenrz opened this issue 9 years ago • 3 comments

hmm. I installed my grpc with $ brew tap grpc $ brew install grpc/grpc

Then I tried to install grpc python with $ sudo pip install virtualenv $ virtualenv venv $ source venv/bin/activate $ curl -fsSL https://goo.gl/getgrpc | bash -s python

No error happened, but when I try to import google.protobuf in my python code, it complains google.protobuf cannot be found.

I'm able to from grpc.beta import implementations But the following line gives an error: from google.protobuf import descriptor as _descriptor ImportError: No module named google.protobuf

awakenrz avatar Nov 13 '15 07:11 awakenrz

@tbetbetbe Is brew-install supposed to check for and pull in dependencies? If so, should proto3 have a brew-thing?

soltanmm avatar Nov 17 '15 02:11 soltanmm

I've also encountered this issue.

brew install grpc/grpc/google-protobuf ==> Installing google-protobuf from grpc/grpc ==> Downloading https://github.com/google/protobuf/archive/v3.0.0.tar.gz Already downloaded: /Users/ezhang6/Library/Caches/Homebrew/google-protobuf-3.0.0.tar.gz ==> ./autogen.sh Last 15 lines from /Users/ezhang6/Library/Logs/Homebrew/google-protobuf/01.autogen.sh: 2016-08-29 18:37:10 +0800

./autogen.sh

Google Mock not present. Fetching gmock-1.7.0 from the web... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1582 100 1582 0 0 686 0 0:00:02 0:00:02 --:--:-- 687 [gmock-1.7.0.zip] End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of gmock-1.7.0.zip or gmock-1.7.0.zip.zip, and cannot find gmock-1.7.0.zip.ZIP, period.

READ THIS: https://git.io/brew-troubleshooting If reporting this issue please do so at (not Homebrew/brew): https://github.com/grpc/homebrew-grpc/issues

These open issues may also help: grpc python installed with virtualenv, code complains no google.protobuf found on Mac OS X https://github.com/grpc/homebrew-grpc/issues/71

eonezhang avatar Aug 29 '16 10:08 eonezhang

I just encountered the same problem you described, @eonezhang. The problem with the autogen.sh is that the curl invocation that is attempting to pull gmock is getting a 404. Gmock is available on Github, though, so I tried changing autogen.sh like so:

-- autogen.sh   2016-07-27 14:40:30.000000000 -0700
+++ autogen.fixed.sh    2016-08-31 01:21:44.000000000 -0700
@@ -31,10 +31,10 @@
 # directory is set up as an SVN external.
 if test ! -e gmock; then
   echo "Google Mock not present.  Fetching gmock-1.7.0 from the web..."
-  curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
+  curl $curlopts -L -o gmock-1.7.0.zip https://github.com/google/googlemock/archive/release-1.7.0.zip
   unzip -q gmock-1.7.0.zip
   rm gmock-1.7.0.zip
-  mv gmock-1.7.0 gmock
+  mv googlemock-release-1.7.0 gmock
 fi

This got me past the error above. However, since I'm messing with the contents of the protobuf tarball directly, this is a protobuf issue, not a Homebrew issue. Protobuf itself has been fixed, but this change is not contained in a released version yet.

If you are willing to brew install google-protobuf --HEAD, though, it will install successfully. Alternatively, you can temporarily avoid using Homebrew for protobuf and download the binary installation from Github and just install this into your /usr/local hierarchy until a new version is released with the fix and it gets picked up by Homebrew.

hasIan avatar Aug 31 '16 08:08 hasIan