enivium
enivium

Reputation: 150

Unable to Import Google Protobuf Python Module

I am working with an Ubuntu 14.04 machine, trying to import the google.protobuf module into python 2.7.

I have tried

apt-get python-protobuf 

and

pip install protobuf 

without success.

Inside python, I get an error saying:

"ImportError: No module named google.protobuf"

Edit 1:

Sorry and thank you to everyone who commented. I'm still new to Ubuntu and StackOverflow.

Specifically, I type in to command line

python
import google.protobuf

and get the feedback

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: No module named google.protobuf

I then type

exit()

I tried inputting

sudo apt-get install python-protobuf

which responds with

Reading package lists... Done Building dependency tree
Reading state information... Done python-protobuf is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 283 not upgraded.

Then I go back into python and try

import google.protobuf

again, but I get exactly the same error as before.

Finally, I tried

pip install protobuf

which responded with

Requirement already satisfied: protobuf in /usr/local/lib/python2.7/dist-packages

Requirement already satisfied: six>=1.9 in /usr/local/lib/python2.7/dist-packages (from protobuf)

Requirement already satisfied: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf)

I tried

python
import google.protobuf

and got exactly the same error. Putting

import protobuf

into python also gets the same error.

Some related information: I have tried doing multiple uninstalls/reinstalls with both apt-get and pip to fix th error, with no change. Also, one of the first things I did after getting Ubuntu was to download python 2.7 from the website and install it, not realizing python came with Ubuntu.

Thanks again.

Upvotes: 10

Views: 11205

Answers (1)

leon wu
leon wu

Reputation: 315

pip install --ignore-installed six

sudo pip install protobuf

Upvotes: 1

Related Questions