Forums

yfinance

Hi I want to use the module yfinance for financial data. I've gone to bash in pythonanywhere and installed it successfully. When i enter python 2, it can see that yfinance is successfully installed and help(yfinance) works here. but in python3 but python3 it doesn't work and python3 when i type into it import yfinance it says:

Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'yfinance'

how can i solve this problem?

To install things to python 3 you need to call pip3 e.g.

pip3 install yfinance

Python2 and Python3 are seperate installations so modules need to be installed seperately.

Also pip3 is for default python3. You can specify the version using pip3.7 or pip3.8 etc.

thank you, but something is still wrong. i'm getting the following code even though now yfinance, pandas and numpy are installed strange because everything works on localhost already tried downgrading numpy as well but i can't go below where i am since tensor flow needs the version i am at or higher (i have numpy 1.17.3)

Traceback (most recent call last): File "/home/grappler185/mysite/hello_flask.py", line 44, in <module> app.run() File "/usr/lib/python3.8/site-packages/flask/app.py", line 990, in run run_simple(host, port, self, **options) File "/usr/lib/python3.8/site-packages/werkzeug/serving.py", line 1010, in run_simple inner() File "/usr/lib/python3.8/site-packages/werkzeug/serving.py", line 954, in inner srv = make_server( Traceback (most recent call last): File "/home/grappler185/mysite/hello_flask.py", line 2, in <module> import yfinance as yf File "/home/grappler185/.local/lib/python3.8/site-packages/yfinance/init.py", line 25, in <module> from .ticker import Ticker File "/home/grappler185/.local/lib/python3.8/site-packages/yfinance/ticker.py", line 27, in <module> import pandas as _pd Traceback (most recent call last): File "/home/grappler185/mysite/hello_flask.py", line 2, in <module> import yfinance as yf File "/home/grappler185/.local/lib/python3.8/site-packages/yfinance/init.py", line 25, in <module> from .ticker import Ticker File "/home/grappler185/.local/lib/python3.8/site-packages/yfinance/ticker.py", line 27, in <module> import pandas as _pd File "/usr/lib/python3.8/site-packages/pandas/init.py", line 11, in <module> import(dependency) File "/usr/lib/python3.8/site-packages/numpy/init.py", line 142, in <module> from . import core File "/usr/lib/python3.8/site-packages/numpy/core/init.py", line 17, in <module> from . import multiarray File "/usr/lib/python3.8/site-packages/numpy/core/multiarray.py", line 14, in <module> from . import overrides File "/usr/lib/python3.8/site-packages/numpy/core/overrides.py", line 16, in <module> add_docstring( RuntimeError: implement_array_function method already has a docstring

The most recent version of NumPy has a bug that means it generates that error if it's imported twice in the same process.

I'm having the same problem, unable to uninstall numpy too.

Anyone has any solution for this ?

You can either use an older version of numpy, or you can not use the Run button to run your code and instead run it from a separate Bash console. Then each new run will be in a new process and the bug will not be triggered.