I Am Getting Attribute Error: 'Module' Object Has No Attribute 'Enabletrace' While Running a Python Code
I Am Using Python 2.7 and I Have Installed the Module Websocket-Client 0.40.0 but I Am Getting the Attribute Error as I Mentioned Above. This Is My Code, I Am...
I am using python 2.7 and I have installed the module websocket-client 0.40.0 but I am getting the attribute error as I mentioned above.
This is my code, I am trying to connect my PC to a microcontroller board through websocket
import websocket
import nltk
from nltk.tokenize import PunktSentenceTokenizer
import sys
import urllib
import urlparse
from urllib2 import HTTPError
from urllib2 import URLError
from getch import getch, pause
import numpy as np
websocket.enableTrace(True)
ws = websocket.create_connection("ws://169.254.7.144:1234")
When I run this program I am getting the error
File "on_laptop.py", line 35, in
websocket.enableTrace(True)
AttributeError: 'module' object has no attribute 'enableTrace'
3 Answers
You've probably installed the websocket package (which doesn't have an enableTrace method) instead of websocket-client.
pip install websocket-client should solve your problem.
Don't forget to uninstall websocket, uninstall websocket-client if you already intalled it before, then re install websocket-client:
- pip uninstall websocket
- pip uninstall websocket-client
- pip install websocket-client
For anyone who finds this issue later on (since it is currently the top hit on Google for this particular issue).
In addition to the already existing solutions, also make sure you do not have a file named "websocket.py". If you do, this will override the websocket-client module.