我收到属性错误:'module'对象在运行python代码时没有属性'enableTrace'

问题描述 投票:2回答:1

我正在使用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行,in

websocket.enableTrace(True)

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

python-2.7 websocket python-import python-module
1个回答
0
投票

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

pip install websocket-client应该解决你的问题。

© www.soinside.com 2019 - 2024. All rights reserved.