yfinance installed: under tools and “yf_fund.py”: import yfinance as yf: error
msg: No module named ‘yfinance’ in “yf_fund.py”
@Per_Bjarte_Solibakke Please edit the question. Give us more information about the error, and add the code.
The crewai work perfect without adding yfiance tools. When I add folling command in crew.py:
from financial_analyst.tools.yf_fundamental_analysis import yf_fundamental_analysis
and my program lines in tools: yf_fundamental_analysis.py is:
import yfinance as yf
from crewai_tools import tool
@tool
def yf_fundamental_analysis(ticker: str):
…
Running crewai run gives:
File “\home.ansatt.ntnu.no\perbso\python\crewai\financial_analyst\src\financial_analyst\tools\yf_fundamental_analysis.py”, line 1, in
import yfinance as yf
ModuleNotFoundError: No module named ‘yfinance’
An error occurred while running the crew: Command ‘[‘uv’, ‘run’, ‘run_crew’]’ returned non-zero exit status 1.
yfinance is installed in the environment. pip freeze confirms it!
Why does not import yfinance work?
Thank you.
Did you find a solution? I’m facing a similar issue.
The environment is set up correctly, and the required libraries are installed via pip
. I can confirm this by running pip list | findstr gradio_client
, which shows the library is present. However, when I try to run the crew using crewai run
, I get the following error:
ModuleNotFoundError: No module named 'gradio_client'
An error occurred while running the crew: Command '['uv', 'run', 'run_crew']' returned non-zero exit status 1.
To debug, I created a simple “echo” tool with no external dependencies, and it worked fine. But as soon as I included the external library (from gradio_client import Client
) in my custom tool, the issue appeared.
Here’s what I’ve tried so far:
- Reinstalled the
gradio_client
library (using--force-reinstall
). - Created a fresh virtual environment and reinstalled everything.
- Confirmed that the
__init__.py
file is correctly placed underproject\src\gemini\tools
. - Verified that a standalone Python script using
gradio_client
works perfectly when run withpython gradio_script.py
.
I’m running this on Windows 11 Pro with Python 3.10.
Any insights or solutions would be greatly appreciated!
I found the solution:
You have to install for example “yfinance” plus all needed prgrams with the command:
uv add yfinance
in the directory where the file “uv.lock” is defined for your application.
This will add the necessary modules!
PBS
It works now! thank you!