Forums

Try pip install but failed

I am trying to install yfinance but return this error

try pip2.7 install --user yfinance also return same error

09:37 ~ $ pip2.7 install --user yfinance --upgrade --no-cache-dir
Collecting yfinance
  Downloading https://files.pythonhosted.org/packages/79/bd/d64719da8f5367f4d8b16e83507fa1d90942f433f748a4cf3ed7aa515d14/yfinance-0.1.63.tar.gz
Collecting pandas>=0.24 (from yfinance)
  Downloading https://files.pythonhosted.org/packages/53/05/bf382e8bc60731906a2e7261648bcea3a6b309ad2b9952010737a1b9413e/pandas-1.3.0.tar.gz (4.7MB)
    100% |████████████████████████████████| 4.7MB 56.8MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-3kONdz/pandas/setup.py", line 249
        f"{extension}-source file '{sourcefile}' not found.\n"
                                                             ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-3kONdz/pandas/

I am just a normal user, but my understanding is that "pip2.7" uses a python version 2.7. This version is pretty old and I had a look on the pandas installation guide. They recommend python version 3.7.1 or above for pandas 1.3.0, which was downloaded in your case. Maybe this results in the error.

But yfinance said it support from 2.7 and above https://github.com/ranaroussi/yfinance Do you understand what is the error means? Thanks

Reading the requirements on https://pypi.org/project/yfinance/ shows that it was tested with a very young version of pandas

Requirements: Python >= 2.7, 3.4+, Pandas (tested to work with >=0.23.1), Numpy >= 1.11.1, requests >= 2.14.2, lxml >= 4.5.1

your pip-command tries to install the latest one (1.3.0), which is not supported. Maybe try to install manually pandas 0.23.1 and after that yfinance

OK. will give it a try. Thanks

Do you know if I can install it with pip3.6, and use it for one of the python scripts.

Example I used finance for python 3.6 for abc.py

But the remaining of my python scripts are 2.7 and I don't have virtualenv.

I would like to run a bash for abc.py (in 3.6) and xyz.py (in 2.7). Is that possible?

yfinance could work on 2.7, but modern pandas is not.

may I know what you refer as modern pandas? Do you mean I need to use an old version of pandas?

If you want to use Python 2.7, then you will need to use a version of pandas that is compatible with Python 2.7.