Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

375
Vistas
AttributeError: 'module' object has no attribute 'WebSocketApp'

I'm trying to connect to an API with python, using WebSocketApp, and I cannot seem to do it. No matter what I try, I keep getting this error:

AttributeError: 'module' object has no attribute 'WebSocketApp'

Here is the simple code I am using

import websocket
import json

def on_open(ws):
    json_data = json.dumps({'data':'value'})
    ws.send(json_data)

def on_message(ws, message):
    print('data update: %s' % message)

if __name__ == "__main__":
    apiUrl = "appurl"
    ws = websocket.WebSocketApp(apiUrl, on_message = on_message, on_open = on_open)
    ws.run_forever()

Any help will be greatly appreciated, all the solutions I have found online have not worked for me.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

It looks like you're trying to use features of the websocket-client package and not just the websocket package. Pip-install websocket-client from the command line (or install it using whatever other package manager you have), then try running your code again.

pip install websocket-client
over 4 years ago · Santiago Trujillo Denunciar

0

Make sure that you didn't name your file as websocket.py; Otherwise, it will prevent import of the desired third-party module websocket; because your module is searched first according to sys.path module search path.

Rename your module to other name, and make sure to clean websocket.pyc if there it is.

over 4 years ago · Santiago Trujillo Denunciar

0

In this case, You should uninstall the possible inconsistent previous versions and install websocket-client again:

pip uninstall websocket-client
pip uninstall websocket

an then install a new version:

pip install websocket-client
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda