Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 support #37

Open
s-celles opened this issue Aug 22, 2015 · 3 comments
Open

Python 3 support #37

s-celles opened this issue Aug 22, 2015 · 3 comments

Comments

@s-celles
Copy link

Hello,

I think python-highcharts doesn't support Python 3

In [1]: import charts
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-5eb3a6e89685> in <module>()
----> 1 import charts

//anaconda/lib/python3.4/site-packages/charts/__init__.py in <module>()
      3 __version__ = '0.4.3'
      4
----> 5 from plot import plot, plotasync, line, area, spline, pie
      6 from server import run_server
      7

ImportError: No module named 'plot'

because same import with Python 2 works fine

I'm using Anaconda Python with Python 3 as default Python install and I can switch to Python 2 using

$ source activate py2

Inspired from http://continuum.io/blog/anaconda-python-3

Any idea ?

@arnoutaertgeerts
Copy link
Owner

@scls19fr If don't really know how to immediately solve this problem but I'm happy to implement it if you found a solution! Let me know or create a pull request :)

@joelion
Copy link

joelion commented Sep 10, 2015

The particular ImportError that @scls19fr mentioned can be fixed in python3 by using relative paths to modules, like shown here
http://stackoverflow.com/questions/14216200/force-importing-module-from-current-directory

However, after fixing that, there are still many other problems in python3, including all of the print statements and SimpleHTTPServer being replaced by http.server. There may be others, but i'm not sure. Have you tried running the 2to3 tool just to see if that works?
https://docs.python.org/2/library/2to3.html
I'm not sure how you're supposed to maintain backwards compatibility once you convert to python3, though.

@s-celles
Copy link
Author

six can help to maintain backward compatibility

https://pythonhosted.org/six/

an other approach is to maintain backward compatibility by yourself in a compat.py file with try / except.

Anyway six code can help
https://github.com/kelp404/six/blob/master/six.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants