How to use YOWSUP (The python WhatsApp library) in ubuntu

Yowsup is a python library that allows you to login and use the WhatsApp service and provides you with all capabilities of an official WhatsApp client, allowing you to create a full-fledged custom WhatsApp client.



sudo apt-get update

Prepare the system with the necessary components to Yowsup

sudo apt-get install python-dateutil
sudo apt-get install python-setuptools
sudo apt-get install python-dev
sudo apt-get install libevent-dev
sudo apt-get install ncurses-dev

I’m available for hire!

This is my email link:

Download the library with the command

git clone git://

Navigate to the folder

cd yowsup

and install the library with the command

sudo python install


After installing the library we have to register the device to use WhatsApp. Yowsup comes with a cross platform command-line frontend called yowsup-cli. It provides you with the options of registration, and provides a few demos such as a command line client.

    • First of all create a file vim
    • Now paste the code from this file.
    • Then save and quit the file.

I’m available for hire!

This is my email link:

  • Now, Download latest version of WhatsApp from here
  • Copy the Downloaded WhatsApp.apk to current directory.
  • Run the command python WhatsApp.apk
  • You will get the output like
    Version: 2.17.344
    ClassesDex: OxVSHnBDYNBZmSiYzwF9+A==
  • You have to write that in

    (replacing _MD5_CLASSES and _VERSION vars) then run:

  • python build
  • python install

WhatsApp registration involves 2 steps. First you need to request a registration code. And then you resume the registration with code you got.

Request a code with command

python yowsup-cli registration --requestcode sms --phone 91xxxxxxxxxx --cc 91 --mcc 222 --mnc 10 -E android

Please add country code as well before mobile no.

Replace with your data ,

cc is your country code in this example 91 is for India,

mcc is Mobile Country Code check your here

mnc is Mobile Network Code check your here

You should receive on your phone a sms message with a code like xxx-xxx

Send a message to request registration with this command, (replace xxx-xxx with code you received)

python yowsup-cli registration --register xxx-xxx --phone 91xxxxxxxxxx --cc 91 -E android

If all goes well, we should get a message like this

status: ok
kind: free
pw: xxxxxxxxxxxxxxxxxx= #this is the password
price: ₹ 55
price_expiration: 1509040085
currency: INR
cost: 55.00
expiration: 4444444444.0
login: 91xxxxxxxxxx
type: new

Create a file to save your credentials in current directory

I’m available for hire!

This is my email link:

sudo vim config

with this content

## Actual config starts below ##
  cc=91 #if not specified it will be autodetected

Ok, we’re ready for the test,

I’m available for hire!

This is my email link:

yowsup-cli demos --yowsup --config config

You can see Yowsup prompt

If type “/help” you can see all available commands

First use the ‘/L’ command for login; to send a message type

/message send 91xxxxxxxxxx "This is a message sent from Command line"

replace xxx with the recipient number

If you respond with a message it will be displayed.

Thanks. 🙂


46 thoughts on “How to use YOWSUP (The python WhatsApp library) in ubuntu”

  1. connected]:/message broadcast 91xxxxxxxxxx “hi”
    Sent: 1507379830-4
    I am not getting any error and not receive the message


  2. Hi , i installed it and tried your advices , with successful registration , but when i use the command , yowsup-cli demos –yowsup –config config
    where the config file supplied with my mobile and password , but it still showed ,

    [offline] : /L
    general: Disconnected: Connection Closed

    any further advice ? Thanks.


  3. i need help to install yowsup api,
    if any can help me intall and teach me how to use i ill pay for this help
    whatsapp +923218355022


  4. Hi,

    Thank you for providing such a clear demonstration.

    I have managed to register (android) however when using yowsup-cli demos I get

    “`general: Login Failed, reason: not-authorized
    Auth Error, reason not-authorized


    “`general: Login Failed, reason: not-authorized, reason: Authentication Failure
    Auth Error, reason not-authorized

    I don’t think I am banned because if I download whatsapp on the handset I registered I can use it to send/receive just fine.

    In I have changed _MD5_CLASSES & _VERSION, did you change _KEY too?
    Also in DEFAULT = Android.

    Any suggestions?
    Thanks in advance.


  5. hm… got strange error on python WhatsApp.apk:

    credBlocks:PAY: IndiaUPIAppActivity onLibraryResult for credentials: 4PAY: IndiaUPIAppActivity onLibraryResult got error: 7PAY: IndiaUPIAppActivity onLibraryResult for resend otp PAY: startShowPinFlow at count: max: 3; showErrorAndFinish#PAY: onRegisterApp got registered: ; showErrorAndFinishinitial#PAY: onGetChallenge got challenge:


  6. Hi, after I run command yowsup-cli registration –requestcode sms -p 6013375xxxx –cc 60 –mcc 502 –mnc 13 -E android -d, I’m getting error bad_token. Can you help please?


    1. My mistake. I can get the code and successfully registered. But when I try the next step to login, I get this error;

      general: Login Failed, reason: not-authorized
      Auth Error, reason not-authorized


  7. Hi, I have the same problem of Azizyaakup.
    general: Login Failed, reason: not-authorized
    Auth Error, reason not-authorized
    Can you help me, please?


  8. Thanks a lot for sharing this! Can you please explain how does this method with downloading apk file is different from other solutions like which do not require apk. Is it better from banning perspective? Would appreciate detailed explanatation since trying to get into field deeper and bans are very critical for many. Thanks in advance


  9. Hello, I followed all the steps but returned the following:
    yowsup marcus$ python yowsup-cli registration –requestcode sms –phone 551143496189 –cc 55 –mcc 724 –mnc 06 -E android
    yowsup-cli v2.0.15
    yowsup v2.5.7

    Copyright (c) 2012-2016 Tarek Galal

    This software is provided free of charge. Copying and redistribution is

    If you appreciate this software and you would like to support future
    development please consider donating:


    status: fail
    param: number
    reason: bad_param
    login: 551143496189

    Whatsapp version:
    Version: 2.18.62
    ClassesDex: KAtYkYa0lEUyKqfhXtmGhw==

    Where did I go wrong?

    Thanks if you can help me.


  10. Hi Jagjeet,
    Awesome tutorial and effort. I have implemented the solution but facing an issue. I’m able to send message to only one contact whenever I try to send message to other contact it Yowsup-cli showing help command.

    I’m also getting below error while executing /L – login command and my terminal hangs(using python 2.7)

    Auth: Logged in!
    [connected]:WARNING:axolotl.sessionbuilder:We’ve already setup a session for this V3 message, letting bundled message fall through…
    Traceback (most recent call last):
    File “/usr/local/bin/yowsup-cli”, line 4, in
    __import__(‘pkg_resources’).run_script(‘yowsup2==2.5.7’, ‘yowsup-cli’)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/”, line 742, in run_script
    self.require(requires)[0].run_script(script_name, ns)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/”, line 1667, in run_script
    exec(code, namespace, namespace)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/EGG-INFO/scripts/yowsup-cli”, line 368, in
    if not parser.process():
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/EGG-INFO/scripts/yowsup-cli”, line 268, in process
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/EGG-INFO/scripts/yowsup-cli”, line 297, in startCmdline
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/demos/cli/”, line 26, in start
    self.stack.loop(timeout = 0.5, discrete = 0.5)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/stacks/”, line 189, in loop
    asyncore.loop(*args, **kwargs)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/”, line 216, in loop
    poll_fun(timeout, map)
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/”, line 156, in poll
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/”, line 87, in read
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/”, line 83, in read
    File “/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/”, line 449, in handle_read_event
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/network/”, line 102, in handle_read
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/network/”, line 110, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/stanzaregulator/”, line 29, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/stanzaregulator/”, line 52, in processReceived
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/stanzaregulator/”, line 49, in processReceived
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/auth/”, line 65, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/coder/”, line 35, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/logger/”, line 14, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 44, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 194, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 41, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 74, in onMessage
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 90, in handleEncMessage
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 159, in handleSenderKeyMessage
    self.parseAndHandleMessageProto(encMessageProtocolEntity, plaintext)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 188, in parseAndHandleMessageProto
    self.handleConversationMessage(node, m.conversation)
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/axolotl/”, line 217, in handleConversationMessage
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 194, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 130, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/protocol_messages/”, line 21, in recvMessageStanza
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/”, line 79, in toUpper
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/layers/interface/”, line 80, in receive
    File “/Library/Python/2.7/site-packages/yowsup2-2.5.7-py2.7.egg/yowsup/demos/cli/”, line 512, in onMessage
    MESSAGE_ID = message.getId()
    UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-6: ordinal not in range(128)



  11. I have tried with python 3.6. I’m getting below error while login

    general: Login Failed, reason: not-authorized
    Auth Error, reason not-authorized

    I’m on mac system
    Please help


  12. hello,

    I have install yowsup and registered my mobile no by mistake i removed yowsup directory. so i doing same process again at that time i am not able to register my same mobile
    it gives below response

    status: b’fail’
    reason: b’blocked’

    please help me

    i have to re-registered mobile no again ?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s