stitchfix / pyxley

Python helpers for building dashboards using Flask and React
MIT License
2.27k stars 257 forks source link

Python 3.4 support? #5

Closed ianozsvald closed 9 years ago

ianozsvald commented 9 years ago

Hello, thanks for the library. This might be the tool that helps me stop showing other data scientists how to write new Flask(+swagger) apps from a template.

I'm a Python 3.4 developer (I'll also note https://github.com/stitchfix/pyxley/issues/4), I can't get pyxley running. Firstly - maybe you could mark in the README that only Python 2.7 is supported at present?

I tried running 2to3 --write pyxley/ after a git-clone and it said it succeeded (so all the files might now be Python 3.4 compatible). I then ran python setup.py install which also succeeded. Oddly I had to run pip install pyreact by hand, I'm not sure if there's a problem with the conversion process.

I started to follow the guide here http://multithreaded.stitchfix.com/blog/2015/07/16/pyxley/ but the first imports fail (from pyxley.utils import FilterFrame - no .utils?). I then tried running the included examples but had errors due to the 2to3 conversion and str datatypes e.g.

pyxley/examples/datamaps/project $ python app.py

Traceback (most recent call last):
  File "app.py", line 55, in <module>
    sb = ui.render_layout(app, "./static/layout.js")
  File "/home/ian/anaconda/envs/scratch/lib/python3.4/site-packages/pyxley/ui.py", line 90, in render_layout
    static_path=path)
  File "/home/ian/anaconda/envs/scratch/lib/python3.4/site-packages/pyxley/react_template.py", line 64, in __init__
    self.to_js()
  File "/home/ian/anaconda/envs/scratch/lib/python3.4/site-packages/pyxley/react_template.py", line 25, in to_js
    self.write_to_file(js)
  File "/home/ian/anaconda/envs/scratch/lib/python3.4/site-packages/pyxley/react_template.py", line 17, in write_to_file
    f.write(s)
TypeError: 'str' does not support the buffer interface

The above error occurs for datamaps, metricsgraphics, datatables.

I'll try using Python 2.7 at some point.

ppope commented 9 years ago

+1 to noting in README that only python 2.7 is supported currently

nmkridler commented 9 years ago

I haven't had a chance to look at 3.4 yet, but thanks for looking in to this. In the meantime, I'll definitely add to the readme that only python 2.7 is currently supported.

nmkridler commented 9 years ago

I got it working in python 3.4, there were some string/binary issues in the writing of layout.js. I'll try to push a fix soon.

nmkridler commented 9 years ago

@ianozsvald Should be 3.4 compatible now. Also, I'll edit the blog to remove the FilterFrame bit. It was removed, but I didn't catch it in the blog.

ianozsvald commented 9 years ago

@nmkridler Hi Nick - just to say "thanks" for fixing this, Python 3.4+ compatibility is much appreciated :-)

qichaotang commented 8 years ago

Hello,nmkridler,the error occurs F:\Anaconda\python.exe F:/Anaconda/selenium/pyxley/examples/metricsgraphics/project/test.py Traceback (most recent call last): File "F:/Anaconda/selenium/pyxley/examples/metricsgraphics/project/test.py", line 80, in sb = ui.render_layout(app, "./static/layout.js") File "F:\Anaconda\lib\site-packages\pyxley\ui.py", line 135, in render_layout static_path=path) File "F:\Anaconda\lib\site-packages\pyxley\react_template.py", line 95, in init self.to_js() File "F:\Anaconda\lib\site-packages\pyxley\react_template.py", line 34, in to_js js = self.transformer.transform_string(t.render(**self.args)) File "F:\Anaconda\lib\site-packages\react\jsx.py", line 45, in transform_string raise TransformError(e.message[7:]) react.jsx.TransformError

Process finished with exit code 1

All examples occurred this problem,I need help.