ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
13.24k stars 2.34k forks source link

Deploying to Google Cloud Functions results in a FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/py-yfinance' #1702

Closed labibk00 closed 1 year ago

labibk00 commented 1 year ago

Describe bug

Error FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/py-yfinance' from Google Cloud logs.

I am trying to deploy this as a part of a personal project and I get the error as a part of the build process in google cloud and the function fails to deploy.

This might be because Google's cloud functions runs automated tests and some part of the yfinance module is broken.

Simple code that reproduces your problem

Does not matter. Simply having the package as a dependency and calling ticker = yf.Ticker(str(symbol), session=session) fails the deployment

Debug log

FileNotFoundError: [Errno 2] No such file or directory: '/root/.cache/py-yfinance'

Bad data proof

No response

yfinance version

0.2.30

Python version

3.11

Operating system

Google Cloud Functions

ValueRaider commented 1 year ago

Is this same as #1700?

justindavies commented 1 year ago

Seeing the same thing happen on Azure functions too

rickturner2001 commented 1 year ago

I remember this happening to me. Essentially if you were to run this in an ec2 instance, then you'd have no problems because you're essentially deploying your code in a place where the file system can be accessed, because it's running on a virtual machine.

In your case and in @justindavies case, you are deploying your code on the edge. This means that you would have to establish a connection to a server based database like postgres, as opposed to a file based database like sqlite

I think a good solution for this would be not to cache anything when a file based database cannot be created.

ValueRaider commented 1 year ago

@rickturner2001 Agree. This is a regression, not intended behaviour. But I'm gonna guess this is same as #1700 so move discussion there.