Kalyan
Kalyan

Reputation: 1938

Getting Error :/usr/bin/python: No module named thrift_compiler

I am trying to run a simple thrift communication using cpp in ubuntu 16.04.my thrift folder is in usr/local/, and my thrift.pc file is in usr/local/lib/pkgconfig.my python folder both 2.7 and 3.5 version are in usr/local/lib folder. I am following this site for creating a simple client server communication http://www.avabodh.com/thrift/client_server.html

so i have written a simple calculator.thrift file code

namspace cpp example
service Calculator
{
    i64 add(1:i32 num1, 2:i32 num2);
}

in my home folder and run

python -m thrift_compiler.main --gen cpp2 calculator.thrift

I am getting this error when i am going to generate gen-cpp2 folder which contains all generated cpp files

/usr/bin/python: No module named thrift_compiler

my thrift server version is 0.9.3. I am very new with thrift protocol.kindly help me to figure out. Thank you

Upvotes: 0

Views: 1087

Answers (1)

JensG
JensG

Reputation: 13411

IIRC the python-based compiler has been removed from the sources a while ago. Here's the official Python tutorial which should also work with the rather old version 0.9.3

In a nutshell, you need to make install the Thrift compiler, then run it as described in the tutorial to generate the code from the IDL:

thrift  --gen cpp  calculator.thrift

To get more info about cmdline parameters type

thrift  --help

Upvotes: 1

Related Questions