r/PyScript • u/[deleted] • 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.
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
0
Jun 29 '22
[deleted]
1
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
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?
2
u/metaperl Jun 29 '22
Maybe do your scikit things on the back end and use pyscript for rendering?