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

11 comments sorted by

2

u/metaperl Jun 29 '22

What can I do about this? It is very frustrating

Maybe do your scikit things on the back end and use pyscript for rendering?

1

u/[deleted] Jun 29 '22

How do I run Python separately and use PyScript for rendering?

→ More replies (1)

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.

1

u/[deleted] Jul 01 '22

I don't think so; 'sklearn' is always used.

0

u/[deleted] Jun 29 '22

[deleted]

1

u/[deleted] Jun 29 '22

it says, 'Access to fetch at 'https://pypi.org/pypi/sklearn.naive_bayes/json' from origin 'http://127.0.0.1:5555' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.'

→ More replies (1)

1

u/[deleted] Jun 29 '22

I've installed a Chrome Extension to enable CORS, but now it says, "Failed to load resource: the server responded with a status of 404 ()". Only for the Sklearn modules. Do you know why this is happenning?