You are using the wrong emit
here. You have to use the emit of the socketio object you created. so instead of
emit('anEvent', jsondata, namespace='/test') # here occurs the error
use:
socketio.emit('anEvent', jsondata, namespace='/test') # here occurs the error