Bokeh에 대한 Udemy 자습서를 따르고 있으며 해결 방법을 찾을 수 없으며 교사로부터 응답을받지 못했습니다. 처음에는 코드에 문제가 있다고 생각했기 때문에 1 주일 정도 지난 후에 코드를 알아 내고 마지막으로 코드를 복사하여 오류가 지속될 때까지 코드를 복사했습니다.주기적인 콜백에서 Bokeh 오류가 발생했습니다.
코드 목적은 라이브 데이터를 긁어 모으는 것입니다. 아래 코드 : 정기적 인 콜백에서 던져
오류 : 던지고
from bokeh.io import curdoc from bokeh.models import ColumnDataSource, DatetimeTickFormatter from bokeh.plotting import figure from random import randrange import requests from bs4 import BeautifulSoup # Create the figure f = figure() # Create webscraping function def extract_value(): r = requests.get("https://bitcoincharts.com/markets/okcoinUSD.html", headers = {'User-Agent' : 'Chrome'}) c = r.content soup = BeautifulSoup(c, "html.parser") value_raw = soup.find_all("p") value_net = float(value_raw[0].span.text) return value_net # Create ColumnDataSource source = ColumnDataSource(dict(x = [], y = [])) # Create glyphs f.circle(x = 'x', y = 'y', color = 'olive', line_color = 'brown', source = source) f.line(x = 'x', y = 'y', source = source) # Create periodic funtion def update(): new_data = dict(x = [source.data['x'][-1]+1], y = [extract_value]) source.stream(new_data, rollover = 200) print(source.data) # Displayed in the commmand line! # Add a figure to curdoc and configure callback curdoc().add_root(f) curdoc().add_periodic_callback(update, 2000)
무슨 일이 일어나고 있는지에 IndexError (' 범위를 벗어난리스트 인덱스')
어떤 아이디어 이리?
나는 동일한 튜토리얼을 따르고 이전 버전의 bokeh를 사용합니다. 그 동안 구문이 변경되었을 수 있습니다. Bokeh는이 관점에서 볼 때 매우 역동적입니다. BeSoup (_html5lib.py) 오류로 인해 BeautifulSoup 및 Bokeh 최신 버전에서 작동하지 않습니다. 현재 어떤 버전을 사용하고 있습니까? 강사가 사용한 것을 설치하려고 했습니까? 어떤 줄에서 오류가 발생합니까? –