Yowsup: ImportError: cannot import name YowAxolotlLayer

Created on 17 Jun 2016  路  9Comments  路  Source: tgalal/yowsup

I am following the sample app tutorial. However I get the following error while executing the code. There are only 3 available layers AxolotlSendLayer, AxolotlControlLayer and AxolotlReceivelayer. Where do I find YowAxolotlLayer?

Traceback (most recent call last):
  File "run.py", line 13, in <module>
    from yowsup.layers.axolotl                     import YowAxolotlLayer
ImportError: cannot import name YowAxolotlLayer

Most helpful comment

Why is this issue closed if the documentation in the master branch has not yet been updated to cover this error?

All 9 comments

YowAxolotlLayer and 'was removed, see here new working scripts

https://github.com/tgalal/yowsup/issues/1648#issuecomment-226345506

Dude, maybe you need to update your libraries, I have the same problem, try whit this: It works for me.
sudo apt-get install python-dateutil
sudo apt-get install python-argparse
sudo apt-get install python-setuptools
sudo apt-get install python-dev
sudo apt-get install libevent-dev
sudo apt-get install ncurses-dev
sudo apt-get install libglib2.0.0
sudo apt-get install libglib2.0-dev
sudo apt-get install libxml2
sudo pip install protobuf
sudo pip install python-axolotl

Also maybe is the ubicaci贸n of your carpet, move to echolist and try again.

I'm haveing the same problem, I need to communicate with my pi with yowsup to execute some functions so I'm useing this two files:

And I run the Listing 2: pitalk.py:

But pitalk.py uses wareceive.py that imports YowAxolotlLayer, so it shows:

Traceback (most recent call last):
  File "pitalk.py", line 3, in <module>
    from warecieve import YowsupReceiveStack, MessageReceived
  File "/home/pi/yowsup/wareceive.py", line 18, in <module>
    from yowsup.layers.axolotl                     import YowAxolotlLayer
ImportError: cannot import name YowAxolotlLayer

Can anyone help me with that using other files or whatever? I will really appriciate this! Thanks!

I'm having the exact same problem, using the same example as mintos002

I have the same problem ... how can we solve this problem?
File "/home/pi/yowsup/wareceive.py", line 18, in
from yowsup.layers.axolotl import YowAxolotlLayer
ImportError: cannot import name YowAxolotlLayer
thanks bruce

The problem is that YowAxolotLayer don't exist anymore so that files don't work. Try with this two files:

run.py

from yowsup.stacks                             import YowStackBuilder
from yowsup.common                             import YowConstants
from yowsup.layers                             import YowLayerEvent
from layer                                     import EchoLayer
from yowsup.layers.auth                        import YowAuthenticationProtocolLayer
from yowsup.layers.coder                       import YowCoderLayer
from yowsup.layers.network                     import YowNetworkLayer
from yowsup.env                                import YowsupEnv

#Uncomment to log
#import logging
#logging.basicConfig(level=logging.DEBUG)

CREDENTIALS = ("phone", "password") #replace with your phone and password

if __name__==  "__main__":
    stackBuilder = YowStackBuilder()

    stack = stackBuilder\
        .pushDefaultLayers(True)\
        .push(EchoLayer)\
        .build()

    stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS)       #setting credentials
    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))          #sending the connect signal
    stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])           #whatsapp server address
    stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)
    stack.setProp(YowCoderLayer.PROP_RESOURCE, YowsupEnv.getCurrent().getResource())  #info about us as WhatsApp client

    stack.loop( timeout = 0.5, discrete = 0.5 )   

layer.py

# -*- coding: utf-8 -*-
import os, subprocess, time
import RPi.GPIO as GPIO

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(14, GPIO.OUT)

from yowsup.layers.interface                           import YowInterfaceLayer                 #Reply to the message
from yowsup.layers.interface                           import ProtocolEntityCallback            #Reply to the message
from yowsup.layers.protocol_messages.protocolentities  import TextMessageProtocolEntity         #Body message
from yowsup.layers.protocol_presence.protocolentities  import AvailablePresenceProtocolEntity   #Online
from yowsup.layers.protocol_presence.protocolentities  import UnavailablePresenceProtocolEntity #Offline
from yowsup.layers.protocol_presence.protocolentities  import PresenceProtocolEntity            #Name presence
from yowsup.layers.protocol_chatstate.protocolentities import OutgoingChatstateProtocolEntity   #is writing, writing pause
from yowsup.common.tools                               import Jid                               #is writing, writing pause

#Log, but only creates the file and writes only if you kill by hand from the console (CTRL + C)
#import sys
#class Logger(object):
#    def __init__(self, filename="Default.log"):
#        self.terminal = sys.stdout
#        self.log = open(filename, "a")
#
#    def write(self, message):
#        self.terminal.write(message)
#        self.log.write(message)
#sys.stdout = Logger("/1.txt")
#print "Hello world !" # this is should be saved in yourlogfilename.txt
#------------#------------#------------#------------#------------#------------

allowedPersons=['44xxxxxxxxx','44xxxxxxxxx'] #Filter the senders numbers
ap = set(allowedPersons)

name = "NAMEPRESENCE"
filelog = "/root/.yowsup/Not allowed.log"

class EchoLayer(YowInterfaceLayer):
    @ProtocolEntityCallback("message")
    def onMessage(self, messageProtocolEntity):
        if messageProtocolEntity.getType() == 'text':
            time.sleep(0.5)
            self.toLower(messageProtocolEntity.ack()) #Set received (double v)
            time.sleep(0.5)
            self.toLower(PresenceProtocolEntity(name = name)) #Set name Presence
            time.sleep(0.5)
            self.toLower(AvailablePresenceProtocolEntity()) #Set online
            time.sleep(0.5)
            self.toLower(messageProtocolEntity.ack(True)) #Set read (double v blue)
            time.sleep(0.5)
            self.toLower(OutgoingChatstateProtocolEntity(OutgoingChatstateProtocolEntity.STATE_TYPING, Jid.normalize(messageProtocolEntity.getFrom(False)) )) #Set is writing
            time.sleep(2)
            self.toLower(OutgoingChatstateProtocolEntity(OutgoingChatstateProtocolEntity.STATE_PAUSED, Jid.normalize(messageProtocolEntity.getFrom(False)) )) #Set no is writing
            time.sleep(1)
            self.onTextMessage(messageProtocolEntity) #Send the answer
            time.sleep(3)
            self.toLower(UnavailablePresenceProtocolEntity()) #Set offline

    @ProtocolEntityCallback("receipt")
    def onReceipt(self, entity):
        print entity.ack()
        self.toLower(entity.ack())

    def onTextMessage(self,messageProtocolEntity):
        namemitt   = messageProtocolEntity.getNotify()
        message    = messageProtocolEntity.getBody().lower()
        recipient  = messageProtocolEntity.getFrom()
        textmsg    = TextMessageProtocolEntity

        #For a break to use the character \n
        #The sleep you write so #time.sleep(1)

        if messageProtocolEntity.getFrom(False) in ap:
            if message == 'hi':
                answer = "Hi "+namemitt+" " 
                self.toLower(textmsg(answer, to = recipient ))
                print answer

            elif message == 'sends the list':
                answer = "Hi "+namemitt+"\n\nYou can ask me these things:\n\nTemperature\nRestart\nOn GPIO14\nOff GPIO14"
                self.toLower(textmsg(answer, to = recipient ))
                print answer

            elif message == 'temperature':
                t=float(subprocess.check_output(["/opt/vc/bin/vcgencmd measure_temp | cut -c6-9"], shell=True)[:-1])
                ts=str(t)
                answer = 'My temperature is '+ts+' 掳C'
                self.toLower(textmsg(answer, to = recipient ))
                print answer

            elif message == 'restart':
                answer = "Ok "+namemitt+", rebooting. Bye bye."
                self.toLower(textmsg(answer, to = recipient ))
                print answer
                time.sleep(3)
                self.toLower(UnavailablePresenceProtocolEntity())
                time.sleep(2)
                os.system('reboot')

            elif message == 'on gpio14':
                GPIO.output(14, True) # Pin 2 in up
                answer = "Ok, il GPIO14 猫 su true"
                self.toLower(textmsg(answer, to = recipient ))
                print answer

            elif message == 'off gpio14':
                GPIO.output(14, False) # Pin 2 in down
                answer = "Ok, il GPIO14 猫 su false"
                self.toLower(textmsg(answer, to = recipient ))
                print answer

            else:
                answer = "Sorry "+namemitt+", I can not understand what you're asking me.." 
                self.toLower(textmsg(answer, to = recipient))
                print answer

        else:
            answer = "Hi "+namemitt+", I'm sorry, I do not want to be rude, but I can not chat with you.."
            time.sleep(20)
            self.toLower(textmsg(answer, to = recipient))
            print answer
            out_file = open(filelog,"a")
            out_file.write("------------------------"+"\n"+"Sender:"+"\n"+namemitt+"\n"+"Number sender:"+"\n"+recipient+"\n"+"Message text:"+"\n"+message+"\n"+"------------------------"+"\n"+"\n")
            out_file.close()

And run the file run.py :D

Thanks mintos002

Why is this issue closed if the documentation in the master branch has not yet been updated to cover this error?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qvs5010 picture qvs5010  路  4Comments

alexvong1995 picture alexvong1995  路  4Comments

EliasinnKamachoo picture EliasinnKamachoo  路  3Comments

ikuraj picture ikuraj  路  5Comments

dickbutt2 picture dickbutt2  路  3Comments