39

I am trying to use Protobuf on Linux box. I downloaded the pre-compiled from github.

When I try to compile my .proto file or just check the protobuf version, it says

protoc: command not found.

I tried the same steps on Windows machine using pre-compiled protobuf version and it works fine there.

James Z
  • 12,209
  • 10
  • 24
  • 44
sgmbd
  • 493
  • 1
  • 6
  • 16

5 Answers5

46

Install protoc for Linux and Mac

Linux

PROTOC_ZIP=protoc-3.15.8-linux-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.15.8/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local include/*
rm -f $PROTOC_ZIP

Mac OS X

brew install protobuf

Alternately, if you don't have Homebrew.

PROTOC_ZIP=protoc-3.15.8-osx-x86_64.zip
curl -OL https://github.com/google/protobuf/releases/download/v3.15.8/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP

source: http://google.github.io/proto-lens/installing-protoc.html

Ninja
  • 2,479
  • 3
  • 23
  • 32
Amit
  • 911
  • 8
  • 23
12

For Linux Ubuntu 20, only install with snap

snap install protobuf --classic

or via apt, with:

sudo apt install protobuf-compiler
GiovannyLucas
  • 129
  • 1
  • 3
5

You can try it:

Install grpc and protobuf

brew install grpc protobuf

Thao Nguyen Tien
  • 851
  • 11
  • 9
5

I know this question is specifically asked for Linux and I could n't find any question as it relates to solving this error on Windows.

This might help people who encounter the same error on windows.

Step 1: Download the windows distribution (protoc-3.5.0-win32.zip) from the link protobuf and unzip locally to a folder

Step 2 : Add the folder path to the path in the system environment variables.

enter image description here

enter image description here

Step 3: close the command prompt, restart the command prompt and try the command protoc

enter image description here

Dharman
  • 30,962
  • 25
  • 85
  • 135
Madhu Tomy
  • 662
  • 11
  • 25
4

I might be late to the party but I also had "command not found" when trying to run protoc. It turned out it was just missing the execute permission. A quick chmod +x protoc fixed this for me.

Richard Adnams
  • 3,128
  • 2
  • 22
  • 30