Reputation:
I used this command line in the terminal to get the module:
$ pip install yahoo-finance
I used this code to check the module was imported correctly, but it says there no module called yahoo_finance
from yahoo_finance import Share
yahoo = Share('YHOO')
print (yahoo.get_price())
What am I missing?
Upvotes: 4
Views: 532
Reputation: 20766
The main reason that yahoo-finance doesn't works, because it's not maintained, latest commit for yahoo-finance
package is 4 years ago. But also you can use a maintained one which is yfinance
To install yfinance with pip;
pip install yfinance
With conda installer;
conda install -c ranaroussi yfinance
You can find more info about yfinance
in this github repository.
Upvotes: 2
Reputation: 8055
I would recommend installing pyenv
to take care of Python's installation. It will allow you to install Python (which will automatically come with its version of pip), and manage different Python versions in your system.
pyenv install 3.8.0
pyenv global 3.8.0 # sets your global Python to 3.8.0
For the time being, what you will want to do is use:
python -m pip install yahoo-finance
This will call the pip
version for the specific python
version that you are running under the python
command -- which can be python2
or python3
, depending on how your PATH
var is set.
Upvotes: 1
Reputation: 629
Check if you use the right version of python
pip install
install library to modules of python 2 while your code is using python3.
Try to use
$ pip3 install yahoo-finance
Upvotes: 4