2017-03-27 41 views
0

我想在heroku上運行散景應用。作爲一個例子,我可以給我從這個website拿下的代碼。requirement.txt在heroku上運行散景應用

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解釋。

但是,在此處或其他地方沒有說明我在使用散景時應將什麼內容添加到requirements.txt文件中。有沒有人可以幫助我解決這個問題以及其他需要做的事情,以便在heroku上運行散景應用程序?

+0

最簡單的方式來創建'requirements.txt'文件,假設您已經有本地安裝的所有代碼,是'pip freeze> requirements.txt'。請注意,如果您不使用每個項目的virtualenv,這可能會包含一些您實際不需要的東西。 – jonrsharpe

+0

或者,如果您使用'conda',則可以運行'conda list --export',但是下面還列出了很短的要求列表。 – bigreddot

回答

0

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取決於熊貓,並且使用自定義擴展取決於是否安裝了NodeJS(通過conda或其他方式)