widgetti / solara

A Pure Python, React-style Framework for Scaling Your Jupyter and Web Apps
https://solara.dev
MIT License
1.62k stars 105 forks source link

Quickstart example does not render correctly with solara run #36

Closed Jhsmit closed 1 year ago

Jhsmit commented 1 year ago

I have a fresh conda environment with python 3.9 on windows. I've used poetry to install solara.

I have a myapp.py file with the following code:

import solara

@solara.component
def Page():
    clicks, set_clicks = solara.use_state(0)
    def increase_clicks():
        set_clicks(clicks+1)
    solara.Button(label=f"Clicked {clicks} times", on_click=increase_clicks)

And then run with:

solara run `myapp.py`

The webpage looks like this: image

These are some of the errors in the console:

The stylesheet http://localhost:8765/_solara/cdn/font-awesome@4.5.0/css/font-awesome.min.css was not loaded because its MIME type, “text/plain”, is not “text/css”.
The script from “http://localhost:8765/_solara/cdn/mermaid@9.1.7/dist/mermaid.min.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type
The script from “http://localhost:8765/_solara/cdn/requirejs@2.3.6/require.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type.
The stylesheet http://localhost:8765/_solara/cdn/@widgetti/solara-vuetify-app@3.0.1/dist/main.css was not loaded because its MIME type, “text/plain”, is not “text/css”.
maartenbreddels commented 1 year ago

Which browser are you using?

maartenbreddels commented 1 year ago

And could you check in the browser dev console, what the response is to http://localhost:8765/_solara/cdn/font-awesome@4.5.0/css/font-awesome.min.css?

Of if you have curl, what is the output of

$ curl -i http://localhost:8765/_solara/cdn/font-awesome@4.5.0/css/font-awesome.min.css
Jhsmit commented 1 year ago

I'm using firefox but I have the same issue with chrome.

I've now tried a clean conda env with pip install solara which gives the same result. the curl output (I run this from another cmd.exe console):

HTTP/1.1 200 OK
date: Thu, 09 Mar 2023 10:51:25 GMT
server: uvicorn
content-type: text/plain; charset=utf-8
content-length: 27466
last-modified: Thu, 09 Mar 2023 10:48:34 GMT
etag: ed21e9c558bbbfbb3b45f91236d4cff8

/*!
 *  Font Awesome 4.5.0 by @davegandy - http://fontawesome.io - @fontawesome
 *  License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)
 */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.5.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.5.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.5.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.5.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.5.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.5.0#font

etc

Jhsmit commented 1 year ago

Chrome:

image

Console: image

maartenbreddels commented 1 year ago

Can you tell me the version number of starlette you have installed ? (pip show starlette)

Jhsmit commented 1 year ago

Name: starlette Version: 0.25.0 Summary: The little ASGI library that shines. Home-page: Author: Author-email: Tom Christie tom@tomchristie.com License: Location: c:\users\jhsmi\miniconda3\envs\py39_solara_pip\lib\site-packages Requires: anyio, typing-extensions Required-by: solara

Jhsmit commented 1 year ago

FYI, in this new environment, I cannot use solara/voila in jupyter lab because it trying to use my 'system' python installation. I've ran pip install ipykernel jupyter here but jupyter doesn't use my conda env python kernel.

Can't remember how I fixed this before, and its probably unrelated

maartenbreddels commented 1 year ago

What do you mean by cannot use? Can you import it? If so, what happens?

Jhsmit commented 1 year ago

I was thinking to see how the example runs in this env in jupyter lab. I run pip install ipykernel jupyter then start jupyter lab with jupyter lab When I then make a notebook and import solara, it cannot find the module. If I print sys.executable it shows C:\python38\python.exe which is my system python installation (from the windows store)

the output of where jupyter:

C:\Users\jhsmi\Miniconda3\envs\py39_solara_pip\Scripts\jupyter.exe
C:\Python38\Scripts\jupyter.exe

So i'm assuming if i run jupyter lab it will use the first one.

maartenbreddels commented 1 year ago

are you using bash for windows? if so, can you run rehash or hash -r, and then make sure which python gives you the right one?

Jhsmit commented 1 year ago

Ok, i've fixed now the jupyter issue, I should do pip install jupyterlab, which is different from pip install jupyter.

The quickstart example now renders correctly in jupyter lab, but still not via solara run