christabor/flask_jsondash

example_app$ python3 app.py does not work

olzhas23 opened this issue · 5 comments

Traceback (most recent call last):
File "app.py", line 7, in
from flask_jsondash.charts_builder import charts
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/flask_jsondash-6.3.3-py3.5.egg/flask_jsondash/charts_builder.py", line 26, in
from .utils import (
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/flask_jsondash-6.3.3-py3.5.egg/flask_jsondash/utils.py", line 15, in
import charts_builder
ImportError: No module named 'charts_builder'

I can reproduce this in python 3.5. Can you try in 2.7 just to confirm? If so, then something is up with the imports. At one point all tests have passed under 2.7-3.6, but Travis has been failing and I haven't had time to dig in. I suspect this is related.

It seems that it's a circular import issue. I don't think it has anything to do with python versions.
Modified the code a bit and created a PR: #160

try this:
from . import charts_builder.py

So the issue is that the utils.py file contains an import charts_builder statement but charts_builder.py somehow depends on utils (I haven't read through all the src yet).

The workaround for me was:

1.) Install any dependencies that setup.py missed (for me was cerberus and pymongo)

2.) Remove import charts_builder from utils.py file

3.) Added import flask_jsondash in app.py

4.) run python3 app.py

screen shot 2018-05-03 at 6 16 32 pm

There was a circular import where utils imports charts_builder, but only needed a sub-folder import within that namespace, so it caused an issue. I fixed that and it works locally when testing in python2.7 and 3.5.

See #162 for more details.