要求.txt在heroku上运行bokeh应用程序

2024-04-20 10:01:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在heroku上运行一个bokeh应用程序。作为一个例子,我可以给出我从这个website获取的以下代码。在

import numpy as np
from numpy import pi

from bokeh.client import push_session
from bokeh.driving import cosine
from bokeh.plotting import figure, curdoc

x = np.linspace(0, 4*pi, 80)
y = np.sin(x)

p = figure()
r1 = p.line([0, 4*pi], [-1, 1], color="firebrick")
r2 = p.line(x, y, color="navy", line_width=4)

# open a session to keep our local document in sync with server
session = push_session(curdoc())

@cosine(w=0.03)
def update(step):
    # updating a single column of the the *same length* is OK
    r2.data_source.data["y"] = y * step
    r2.glyph.line_alpha = 1 - 0.8 * abs(step)

curdoc().add_periodic_callback(update, 50)

session.show(p) # open the document in a browser

session.loop_until_closed() # run forever

所以,要在heroku上运行这个,我发现,我需要执行answer中解释的步骤。在

但是,这里或其他地方没有说明我应该在要求.txt当我使用bokeh时归档。在heroku上运行bokeh应用程序时,有没有人可以帮我解决这个问题和其他需要做的事情?在


Tags: thefromimportnumpy应用程序herokusessionstep
1条回答
网友
1楼 · 发布于 2024-04-20 10:01:01

Bokeh的运行时需求列表非常短。它们在项目setup.py中给出:

REQUIRES = [
    'six >=1.5.2',
    'requests >=1.2.3',
    'PyYAML >=3.10',
    'python-dateutil >=2.1',
    'Jinja2 >=2.7',
    'numpy >=1.7.1',
    'tornado >=4.3',
]

# handle the compat difference for futures 
if sys.version_info[:2] == (2, 7):
    REQUIRES.append('futures >=3.0.3')

有一些可选的依赖关系。bokeh.charts依赖于Pandas,使用自定义扩展依赖于安装nodej(通过conda或其他方式)

相关问题 更多 >