Does YFinance work with PyScript?

I’m a beginner learning financial analysis with Python and I was hoping to import YFinance, pandas and matplotlib to load stock market data onto a website using PyScript. When I try it seems to stay stuck in the loading process, is this too much for PyScript to do on a web browser?

It’s not that it’s “too much” in terms of performance, it’s more that looking at YFinance, in the requirements.txt you’ll see that it uses the package requests which isn’t usable in PyScript

With PyScript all the code is running within your browser and it is therefore subject to the browser’s sandbox and that means it can’t do certain “low level” tasks that a web page also couldn’t do (eg it can’t freely read local files, cannot open up certain kinds of network connection etc)

For some of these things there may eventually be work arounds (ie finding a way to do the task with certain Web APIs so that it looks to the Python code that it happened as normal even though it was effectively handled via some other mechanism). There are some threads able figuring out something for requests because this blocks a lot of tools that rely on it, but I’ve no idea of the timeframe nor how effective any workaround may be, so it could be a bit of a wait.

Hope that helps!

3 Likes

Thanks for the quick response, very helpful!