jwkvam / bowtie

:bowtie: Create a dashboard with python!
MIT License
765 stars 68 forks source link

ImportError: No module named html #229

Closed willupowers closed 6 years ago

willupowers commented 6 years ago

I'm stuck trying to run the example code: https://github.com/jwkvam/bowtie-demo/blob/master/example.py

I believe I have all dependencies installed via conda and pip (plotlywrapper), and I've tried running it in several environments and consoles.

!/usr/bin/env python

... # -- coding: utf-8 -- ... ... from bowtie import App, command ... from bowtie.control import Dropdown, Slider ... from bowtie.visual import Plotly, Table ... from bowtie.html import Markdown ... ... import numpy as np ... import pandas as pd ... import plotlywrapper as pw ... ... from sklearn.kernel_ridge import KernelRidge ... ... iris = pd.read_csv('./iris.csv') ... iris = iris.drop(iris.columns[0], axis=1) ... ... attrs = iris.columns[:-1] ... ... description = Markdown("""Bowtie Demo ... =========== ... ... Demonstrates interactive elements with the iris dataset. ... Select some attributes to plot and select some data on the 2d plot. ... Change the alpha parameter to see how that affects the model. ... """) ... ... xdown = Dropdown(caption='X variable', labels=attrs, values=attrs) ... ydown = Dropdown(caption='Y variable', labels=attrs, values=attrs) ... zdown = Dropdown(caption='Z variable', labels=attrs, values=attrs) ... alphaslider = Slider(caption='alpha parameter', start=10, minimum=1, maximum=50) ... ... mainplot = Plotly() ... mplot3 = Plotly() ... linear = Plotly() ... table1 = Table() ... ... ... def pairplot(x, y): ... print('hellox') ... if x is None or y is None: ... return ... x = x['value'] ... y = y['value'] ... plot = pw.Chart() ... for i, df in iris.groupby('Species'): ... plot += pw.scatter(df[x], df[y], label=i) ... plot.xlabel(x) ... plot.ylabel(y) ... mainplot.do_all(plot.to_json()) ... ... ... def threeplot(x, y, z): ... if x is None or y is None or z is None: ... return ... x = x['value'] ... y = y['value'] ... z = z['value'] ... plot = pw.Chart() ... for i, df in iris.groupby('Species'): ... plot += pw.scatter3d(df[x], df[y], df[z], label=i) ... plot.xlabel(x) ... plot.ylabel(y) ... plot.zlabel(z) ... mplot3.do_all(plot.tojson()) ... ... ... def mainregress(selection, alpha): ... if len(selection) < 2: ... return ... ... x = xdown.get()['value'] ... y = ydown.get()['value'] ... ... tabdata = [] ... mldatax = [] ... mldatay = [] ... species = iris.Species.unique() ... for i, p in enumerate(selection['points']): ... mldatax.append(p['x']) ... mldatay.append(p['y']) ... tabdata.append({ ... x: p['x'], ... y: p['y'], ... 'species': species[p['curve']] ... }) ... ... ... X = np.c[mldatax, np.array(mldatax) 2] ... ridge = KernelRidge(alpha=alpha).fit(X, mldatay) ... ... xspace = np.linspace(min(mldatax)-1, max(mldatax)+1, 100) ... ... plot = pw.scatter(mldatax, mldatay, label='train', markersize=15) ... for i, df in iris.groupby('Species'): ... plot += pw.scatter(df[x], df[y], label=i) ... plot += pw.line(xspace, ridge.predict(np.c_[xspace, xspace2]), label='model', mode='lines') ... plot.xlabel(x) ... plot.ylabel(y) ... linear.do_all(plot.to_json()) ... table1.do_data(pd.DataFrame(tabdata)) ... ... ... @command ... def main(): ... app = App(rows=2, columns=3, background_color='PaleTurquoise', debug=False) ... app.columns[0].fraction(2) ... app.columns[1].fraction(1) ... app.columns[2].fraction(1) ... ... app.add_sidebar(description) ... app.add_sidebar(xdown) ... app.add_sidebar(ydown) ... app.add_sidebar(zdown) ... app.add_sidebar(alphaslider) ... ... app[0, 0] = mainplot ... app[0, 1:] = mplot3 ... app[1, :2] = linear ... app[1, 2] = table1 ... ... app.subscribe(pairplot, xdown.on_change, ydown.on_change) ... app.subscribe(threeplot, xdown.on_change, ydown.on_change, zdown.on_change) ... app.subscribe(mainregress, mainplot.on_select, alphaslider.on_change) ... ... return app ... ImportError: No module named html ImportErrorTraceback (most recent call last)

in () 5 from bowtie.control import Dropdown, Slider 6 from bowtie.visual import Plotly, Table ----> 7 from bowtie.html import Markdown 8 9 import numpy as np ImportError: No module named html
jwkvam commented 6 years ago

Thanks for the report! Can you check what version of bowtie you have installed?

python -c "import bowtie; print(bowtie.__version__)"

If you're not running 0.9.1, please upgrade and try again. If you are running 0.9.1 please let me know.

willupowers commented 6 years ago

My mistake I went into the python shell and executed the code line by line and no errors at:

from bowtie.html import Markdown

./example.py in my system terminal results in:

(py36bowtie) users-MacBook-Pro:bowtie-demo-master user$ ./example.py Usage: example.py [--help] COMMAND [ARGS]...

Bowtie CLI to help build and run your app.

Options: --help Show this message and exit.

Commands: build Write the app, downloads the packages, and... dev Recompile the app for development. prod Recompile the app for production. run Build the app and serve it. serve Serve the Bowtie app. (py36bowtie) users-MacBook-Pro:bowtie-demo-master user$

Looks like my IDE was having path issues with v0.9.1 and v0.8.1 has the issue

jwkvam commented 6 years ago

Cool, thanks for confirming :)