【问题标题】:I am getting Attribute error: 'module' object has no attribute 'enableTrace' while running a python code我收到属性错误:“模块”对象在运行 python 代码时没有属性“enableTrace”
【发布时间】:2017-08-11 20:35:23
【问题描述】:

我使用的是 python 2.7 并且我已经安装了模块 websocket-client 0.40.0 但我收到了上面提到的属性错误。

这是我的代码,我正在尝试通过 websocket 将我的 PC 连接到微控制器板

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") 

当我运行这个程序时,我得到了错误

文件“on_laptop.py”,第 35 行,在

websocket.enableTrace(True)

AttributeError: 'module' 对象没有属性 'enableTrace'

【问题讨论】:

    标签: python-2.7 websocket python-import python-module


    【解决方案1】:

    您可能已经安装了websocket 包(它没有enableTrace 方法)而不是websocket-client

    pip install websocket-client 应该可以解决您的问题。

    【讨论】:

    • 为我解决了!谢谢!
    猜你喜欢
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    相关资源
    最近更新 更多