r/PyScript • • Jun 29 '22
Why is Pyscript taking forever to load after importing Scikit Learn?
So, I'm using PyScript for my website. Using Live Server, my website is taking forever to load after I try to install sklearn. My PyScript code looks like this:
<!DOCTYPE=html>
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
<py-env>
- numpy
- pandas
- sklearn.model_selection
- sklearn.naive_bayes
- sklearn.feature_extraction
</py-env>
<py-script>
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import MultinomialNB
from sklearn.feature_extraction.text import TfidfVectorizer
</py-script>
</body>
</html> However, and note that this only happens when I install skearn, it just says this for (at what seems to be the case at this rate) forever:
Loading runtime... Runtime created... Initializing components...
What can I do about this? It is very frustrating.
5
Upvotes
2
u/metaperl Jun 29 '22
Maybe do your scikit things on the back end and use pyscript for rendering?
1
u/moscamorta Jun 29 '22
Never used pyscript, but I think in your py-env tag, one should use `scikit-learn` and not what you wrote.
3
u/Cheezi_Goodnezz Jun 29 '22
I don’t have a solution, but I had a similar problem when I tried to add the “- json” library. I almost made a post about this, but decided to move on and do something else. This issue is strange, and a solution or acknowledgment from the developers (if appropriate) would be great.
1
u/metaperl Jun 29 '22
Taking a glance at your code, it looks like Gradio might be a good fit. I mention it in my survey.
1
u/metaperl Jul 01 '22
I just came across a medium article where they expose a scikit learn model through Gradio
https://link.medium.com/7eAscaXfjrb
0
u/[deleted] Jun 29 '22
[deleted] — view deleted comment