Yowsup: ImportError

Created on 3 Jan 2015  路  19Comments  路  Source: tgalal/yowsup

i get the following error

matthias@matthias-desktop:~/yowsup$ yowsup-cli
Traceback (most recent call last):
File "/usr/local/bin/yowsup-cli", line 4, in
import('pkg_resources').run_script('yowsup2==2.0.53', 'yowsup-cli')
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 499, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1246, in run_script
exec script_code in namespace, namespace
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.0.53-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 6, in

File "build/bdist.linux-i686/egg/yowsup/demos/cli/init.py", line 1, in
#
File "build/bdist.linux-i686/egg/yowsup/demos/cli/stack.py", line 2, in
File "build/bdist.linux-i686/egg/yowsup/layers/axolotl/init.py", line 1, in
#
File "build/bdist.linux-i686/egg/yowsup/layers/axolotl/layer.py", line 3, in
File "build/bdist.linux-x86_64/egg/axolotl/util/keyhelper.py", line 3, in
File "build/bdist.linux-x86_64/egg/axolotl/identitykeypair.py", line 1, in
File "build/bdist.linux-x86_64/egg/axolotl/state/storageprotos.py", line 9, in
ImportError: cannot import name symbol_database

invalid

Most helpful comment

Hi,
I ran in the same issues (see below) after updating to protobuf to 3.0.0a4 from git:

rf@host:~/src/protobuf/examples$ ./add_person.py 
Traceback (most recent call last):
  File "./add_person.py", line 5, in <module>
    import addressbook_pb2
  File "/home/rf/src/protobuf/examples/addressbook_pb2.py", line 9, in <module>
    from google.protobuf import symbol_database as _symbol_database
ImportError: cannot import name symbol_database

After removing the abandoned python binding of ubuntu via

 sudo apt-get remove python-protobuf

the examples work for me.

All 19 comments

try sudo pip install --upgrade protobuf ?

thx, but nothing changed :-) I get the similar error

matthias@matthias-desktop:~/yowsup$ yowsup-cli
/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py:1180: UserWarning: /home/matthias/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
Traceback (most recent call last):
File "/usr/local/bin/yowsup-cli", line 4, in
import('pkg_resources').run_script('yowsup2==2.0.53', 'yowsup-cli')
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 652, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py", line 1580, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.0.53-py2.7.egg/EGG-INFO/scripts/yowsup-cli", line 6, in

File "build/bdist.linux-i686/egg/yowsup/demos/cli/init.py", line 1, in
#
File "build/bdist.linux-i686/egg/yowsup/demos/cli/stack.py", line 2, in
File "build/bdist.linux-i686/egg/yowsup/layers/axolotl/init.py", line 1, in
#
File "build/bdist.linux-i686/egg/yowsup/layers/axolotl/layer.py", line 3, in
File "build/bdist.linux-x86_64/egg/axolotl/util/keyhelper.py", line 3, in
File "build/bdist.linux-x86_64/egg/axolotl/identitykeypair.py", line 1, in
File "build/bdist.linux-x86_64/egg/axolotl/state/storageprotos.py", line 9, in
ImportError: cannot import name symbol_database
matthias@matthias-desktop:~/yowsup$

which protobuf version do you have, in python console try:

from google import protobuf
print(protobuf.__version__)

print(protobuf.version)
3.0.0-alpha-1

try remove and reinstall protobuf python package

Mhh, after reinstalling i get this message from python console

print(protobuf.version)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'protobuf' is not defined

Make sure protobuf is installed

Sorry but don`t now what is going on. I installed python-protobuf like this:

matthias@matthias-desktop:~$ sudo apt-get install python-protobuf
Paketlisten werden gelesen... Fertig
Abh盲ngigkeitsbaum wird aufgebaut
Statusinformationen werden eingelesen... Fertig
Die folgenden NEUEN Pakete werden installiert:
python-protobuf
0 aktualisiert, 1 neu installiert, 0 zu entfernen und 2 nicht aktualisiert.
Es m眉ssen noch 0 B von 77,5 kB an Archiven heruntergeladen werden.
Nach dieser Operation werden 463 kB Plattenplatz zus盲tzlich benutzt.
Vormals nicht ausgew盲hltes Paket python-protobuf wird gew盲hlt.
(Lese Datenbank ... 222202 Dateien und Verzeichnisse sind derzeit installiert.)
Entpacken von python-protobuf (aus .../python-protobuf_2.4.1-3ubuntu1_i386.deb) ...
python-protobuf (2.4.1-3ubuntu1) wird eingerichtet ...

Everything them to be fine but when i print the version in python i get this:

matthias@matthias-desktop:~$ python
Python 2.7.3 (default, Feb 27 2014, 19:39:10)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

print(protobuf.version)
Traceback (most recent call last):
File "", line 1, in
NameError: name 'protobuf' is not defined

Ok, sorry protobuf version works. Forgot the form google import protobuf

matthias@matthias-desktop:~/yowsup$ python
Python 2.7.3 (default, Feb 27 2014, 19:39:10)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from google import protobuf
print(protobuf.version)
3.0.0-alpha-1

matthias@matthias-desktop:~/yowsup$

But i get the same ImportError

Any ideas??

no sorry, it looks like problems with your protobuf installation which I can't help with :/

Hint: yowsup uses a feature of protobuf (namely "symbol_database") which is only available in recent versions of protobuf.

If you try to use yowsup on a CentOS 6 system, you are out of luck because the EPEL repositories give you protobuf-python version 2.3.something (which is too old). Installing protobuf 2.6.1 via pip is not a solution because you end up with "google" packages in two places:

/usr/lib/python2.6/site-packages/google
/usr/lib/python2.6/site-packages/protobuf-2.6.1-py2.6.egg/google

If you now do "import google" in your application (which yowsup does) you will only get the native directory and its content, not the one inside the egg.

Sorry but i did not understand what you mean. What can i do to make it work?

Hi,
I ran in the same issues (see below) after updating to protobuf to 3.0.0a4 from git:

rf@host:~/src/protobuf/examples$ ./add_person.py 
Traceback (most recent call last):
  File "./add_person.py", line 5, in <module>
    import addressbook_pb2
  File "/home/rf/src/protobuf/examples/addressbook_pb2.py", line 9, in <module>
    from google.protobuf import symbol_database as _symbol_database
ImportError: cannot import name symbol_database

After removing the abandoned python binding of ubuntu via

 sudo apt-get remove python-protobuf

the examples work for me.

@rfelten 's solution did the trick :)

Thanks @rfelten your trick works for me on ubuntu14.04.3

for the probleme
ImportError: cannot import name symbol_database

sudo pip install --upgrade protobuf
works for me

Just in case:
check that you have installed protobuf for the same version of python you are trying to use.

Thanks @LeYangNwpu ! Your recommendation works!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EliasinnKamachoo picture EliasinnKamachoo  路  3Comments

mannemvamsi picture mannemvamsi  路  4Comments

Realitaetsverlust picture Realitaetsverlust  路  4Comments

cyberp1983 picture cyberp1983  路  3Comments

rroqueCoddera picture rroqueCoddera  路  3Comments