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

CSS assets do not seem to load when running in PyCharm #5

Closed
brylie opened this issue Oct 29, 2018 · 17 comments
Closed

CSS assets do not seem to load when running in PyCharm #5

brylie opened this issue Oct 29, 2018 · 17 comments

Comments

@brylie
Copy link

brylie commented Oct 29, 2018

I notice the bootstrap.min.css and custom.css files in the slapdash/assets folder, along with FontAwesome. However, these assets do not seem to load when running the app:

screenshot_20181029_120436

When I navigate to the /assets route in the browser, it says "no page '/assets'".

I ran the project in PyCharm by running the run_flask.py file after installing slapdash in the virtual environment.

@ned2
Copy link
Owner

ned2 commented Oct 29, 2018

Could you try running it from the command line without PyCharm? I've seen issues previously about Dash infrastructure breaking when run through IDEs.

@brylie
Copy link
Author

brylie commented Oct 30, 2018

Sure. FWIW, I am able to run 'regular' Dash project(s) via PyCharm.

@ned2
Copy link
Owner

ned2 commented Oct 30, 2018

Ah ok. I'll try and run Slapdash in PyCharm and see if I can work out what's going on.

@brylie
Copy link
Author

brylie commented Oct 30, 2018

The CSS loads fine when I follow these steps:

  1. clone repo
  2. cd to repo root
  3. run pipenv install then pipenv shell
  4. run pip install -r requirements.txt
  5. run pip install -e .
  6. run ./run_flask.py
  7. open URL in browser

@brylie
Copy link
Author

brylie commented Oct 30, 2018

I will also test using the WSGI approach described in the README.

@brylie
Copy link
Author

brylie commented Oct 30, 2018

Woohoo! The 'package-less' approach works with the following, somewhat convoluted, steps:

  1. clone repo
  2. cd to src
  3. run virtualenv venv
  4. run source venv/bin/activate
  5. pip install -r ../requirements.txt
  6. pip install dash-core-components
  7. pip install dash-html-components
  8. gunicorn slapdash.wsgi
  9. open URL

I somewhat prefer this approach, were the requirements.txt to be in the src directory and include the dash-core-components and dash-html-components.

@ned2
Copy link
Owner

ned2 commented Oct 30, 2018 via email

@brylie
Copy link
Author

brylie commented Oct 30, 2018

Well, I am just thinking it could be easier for a new developer to simply run

  1. pip install -r requirements.txt
  2. python app.py or something similar,

rather than

  1. pip install -r requirements.txt
  2. pip install -e .
  3. python run_server.py, which is somewhat ambiguous.

Otherwise, this is so new to me I haven't formed a richer opinion.

@ned2
Copy link
Owner

ned2 commented Oct 30, 2018 via email

@brylie
Copy link
Author

brylie commented Oct 30, 2018

Ah, thanks for clarification.

@brylie brylie changed the title CSS assets do not seem to load CSS assets do not seem to load when running in PyCharm Oct 31, 2018
@ned2
Copy link
Owner

ned2 commented Nov 5, 2018

I can't replicate the issue, running run_flask.py with PyCharm 2018.2.4 (running on Ubuntu 18.10). What OS are you running on?

Note that /assets is not exposed as a route, only the direct routes to the assets themselves, so that is actually expected, even when the CSS files are being picked up correctly.

Maybe also check that you have the latest Dash installed.

@ned2
Copy link
Owner

ned2 commented Dec 30, 2018

Closing this for now

@ned2 ned2 closed this as completed Dec 30, 2018
@drewes
Copy link

drewes commented Mar 4, 2019

Sorry for coming late to the party. Have the same issue on MacOS with PyCharm 2018.3.

Would prefer to install it as a package.

Tried the following from the command line after cloning repo:

  1. mkdir venv
  2. python3 -p python3 venv
  3. source venv/bin/activate
  4. pip install -e .
  5. python run-flask.py --debug

Server starts. Assets don't seem to load.

Any suggestions?

@drewes
Copy link

drewes commented Mar 5, 2019

Managed to solve it by passing __name__ into the Dash instantiation in your create_dash(server) function.

@ned2 Any advice on best practice? I assume related to your post plotly/dash#198.

@ned2
Copy link
Owner

ned2 commented Mar 5, 2019

Oops, good catch!

It used to be that Dash would take the name parameter from the Flask instance if one was passed in as through the server parameter, but that was removed with plotly/dash#547 to decouple the Dash instance from the Flask instance, in case multiple Dash instances (potentially in different directories) are configured to use the same Flask server. I forgot that slapdash was relying on this behaviour.

This is now fixed in 75f443c

Thanks!

@drewes
Copy link

drewes commented Mar 5, 2019

Thanks for your library! Has helped us tremendously.

@ned2
Copy link
Owner

ned2 commented Mar 5, 2019

Wonderful to hear :)

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