6

I'm using Mac OS and receiving an error when doing the following:

import pandas as pd
import yfinance as yf
from yahoofinancials import YahooFinancials

ModuleNotFoundError: No module named 'yfinance'

I've checked pip is installed to the latest version & I've done pip list and yfinance is in there.

I have also checked with:

pip show yfinance
Name: yfinance
Version: 0.1.70
Summary: Download market data from Yahoo! Finance API
Home-page: https://github.com/ranaroussi/yfinance
Author: Ran Aroussi
Author-email: ran@aroussi.com
License: Apache
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: lxml, multitasking, numpy, pandas, requests
Required-by: 
MacBook-Air:~ User$ 

So it's installed and its path is that of Python3 the latest python.

I'd really appreciate any suggestions!

Thanks

[EDIT]

I'm running Spyder from the default Spyder environment.

user18233539
  • 129
  • 1
  • 2
  • 8
  • 1
    How are you running your script? Have you verified that the same environment you're running script in is the one you're installing packages to? – Random Davis Feb 23 '22 at 16:08
  • I'm running script from the default spyder environment – user18233539 Feb 23 '22 at 16:57
  • Looks like [this post](https://stackoverflow.com/questions/10729116/adding-a-module-specifically-pymorph-to-spyder-python-ide) is relevant, does that help? – Random Davis Feb 23 '22 at 17:08
  • You have missing dependencies! # Mandatory: nbconvert >=4.0 : None (NOK) Please install them to avoid this message. Note: Spyder could work without some of these dependencies, however to have a smooth experience when using Spyder we strongly recommend you to install all the listed missing dependencies. I updated it using the PATHMANAGE but now i have this following error: Failing to install these dependencies might result in bugs. Please be sure that any found bugs are not the direct result of missing dependencies, prior to reporting a new issue. – user18233539 Feb 23 '22 at 18:17
  • Above is the error after I have used the python manager to link to the library. > – user18233539 Feb 23 '22 at 18:18

5 Answers5

7

put this one at the beginning

!pip install yfinance
cottontail
  • 10,268
  • 18
  • 50
  • 51
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 24 '22 at 09:44
1

To install yfinance package with pip:

pip install -i https://pypi.anaconda.org/ranaroussi/simple finance

To install yfinance package with conda:

conda install -c ranaroussi yfinance
0

I had the same error on Linux. Which rectified by forcing reinstall of the package by the following code.

python -m pip install -U --force-reinstall yfinance 

=

Bibin
  • 199
  • 2
  • 10
0

enter image description here

Please check the settings in Python Interpreter and make sure the package yfinance has been installed there. If yfinance cannot be found, please add the package there.

Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
Lee Ricky
  • 1
  • 1
0

Install yfinance

!pip install yfinance

Import the modules if you have already installed

import pandas_datareader as pdr

import pandas as pd

from datetime import datetime

import yfinance as yf

## Download 

df_tesla=yf.download('TSLA')

df_tesla

All works fine then, it worked for me.

toyota Supra
  • 3,181
  • 4
  • 15
  • 19