Dhe*_*omu 8 python-module python-import websocket python-2.7
我正在使用 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")
Run Code Online (Sandbox Code Playgroud)
当我运行这个程序时,我收到错误
文件“on_laptop.py”,第 35 行,位于
websocket.enableTrace(True)
Run Code Online (Sandbox Code Playgroud)
AttributeError:“模块”对象没有属性“enableTrace”
Esc*_*her 17
您可能已经安装了该websocket软件包(它没有enableTrace方法)而不是websocket-client.
pip install websocket-client应该可以解决你的问题。
小智 5
不要忘记卸载websocket,如果之前安装过websocket-client,请卸载它,然后重新安装websocket-client:
小智 5
对于以后发现此问题的任何人(因为它目前是 Google 上针对此特定问题的热门搜索)。
除了现有的解决方案之外,还要确保您没有名为“websocket.py”的文件。如果这样做,这将覆盖 websocket-client 模块。
| 归档时间: |
|
| 查看次数: |
11830 次 |
| 最近记录: |