Forums

ModuleNotFoundError: No module named 'yfinance'

I was updating my server to use yfinance today, however, whenever I try to query my server I end up getting the following in my error logs

2023-01-18 18:49:51,005: Error running WSGI application
2023-01-18 18:49:51,006: ModuleNotFoundError: No module named 'yfinance'
2023-01-18 18:49:51,006:   File "/var/www/efficientfrontier_pythonanywhere_com_wsgi.py", line 111, in <module>
2023-01-18 18:49:51,006:     from flask_app import app as application  # noqa
2023-01-18 18:49:51,006: 
2023-01-18 18:49:51,006:   File "/home/efficientfrontier/efficientFrontierServer/curveSurfing/server/flask_app.py", line 3, in <module>
2023-01-18 18:49:51,006:     from efficientFrontier import EfficientFrontier
2023-01-18 18:49:51,006: 
2023-01-18 18:49:51,007:   File "/home/efficientfrontier/efficientFrontierServer/curveSurfing/server/efficientFrontier.py", line 8, in <module>
2023-01-18 18:49:51,007:     import yfinance
2023-01-18 18:49:51,007: ***************************************************
2023-01-18 18:49:51,007: If you're seeing an import error and don't know why,
2023-01-18 18:49:51,007: we have a dedicated help page to help you debug: 
2023-01-18 18:49:51,007: https://help.pythonanywhere.com/pages/DebuggingImportError/
2023-01-18 18:49:51,007: ***************************************************

I did go to that page and everything did seem to look correct (the REPL was able to import yfinance), however, it is still giving me this issue . I do import other packages however, those all work fine. Notably, I had them imported about a year ago, and yfinance is the only need package I have tried to import today. Any ideas on why this is happening?

I figured it out.

Turns out I was using a venv and I forgot, so I actually needed to install yfinance in that venv and then restart my web app. It works fine now.

Great, glad to hear you worked it out!