Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac OS M1 Chip EmptyDataError #1172

Closed
melgazar9 opened this issue Nov 14, 2022 · 7 comments
Closed

Mac OS M1 Chip EmptyDataError #1172

melgazar9 opened this issue Nov 14, 2022 · 7 comments

Comments

@melgazar9
Copy link

Hi - is EmptyDataError a known issue when running yf.download on MacOS with an M1 chip? When I run the same command on Ubuntu with the exact same requirements.txt everything works as expected. I have confirmed pd.read_csv(<local_file>) works without issue, so I don't think it's a pandas issue.

On m1 chip

source venv/bin/activate
pip install -r requirements.txt
python -V # 3.9.15
python
>>> import yfinance as yf
>>> yf.download('MSFT')
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 980, in _bootstrap_inner
    self.run()
  File "/opt/homebrew/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 917, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/multitasking/__init__.py", line 104, in _run_via_pool
    return callee(*args, **kwargs)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/yfinance/multi.py", line 199, in _download_one_threaded
    data = _download_one(ticker, start, end, auto_adjust, back_adjust,
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/yfinance/multi.py", line 213, in _download_one
    return Ticker(ticker).history(period=period, interval=interval,
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/yfinance/base.py", line 153, in history
    tz = self._get_ticker_tz(debug_mode, proxy, timeout)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/yfinance/base.py", line 335, in _get_ticker_tz
    tkr_tz = utils.cache_lookup_tkr_tz(self.ticker)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/yfinance/utils.py", line 339, in cache_lookup_tkr_tz
    df = _pd.read_csv(fp, index_col="Ticker")
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 950, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 605, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1442, in __init__
    self._engine = self._make_engine(f, self.engine)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1753, in _make_engine
    return mapping[engine](f, **self.options)
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 79, in __init__
    self._reader = parsers.TextReader(src, **kwds)
  File "pandas/_libs/parsers.pyx", line 554, in pandas._libs.parsers.TextReader.__cinit__
pandas.errors.EmptyDataError: No columns to parse from file
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/melgazar9/scripts/github/personal/ds-mono-repo/venv/lib/python3.9/site-packages/yfinance/multi.py", line 118, in download
    _time.sleep(0.01)
KeyboardInterrupt
@melgazar9
Copy link
Author

I upgraded to 0.1.86 which has this fix, but still getting the same error. Can someone else cross validate they're getting this same error with an M1 chip?

@ValueRaider
Copy link
Collaborator

ValueRaider commented Nov 14, 2022

Sorry, I assumed this was same issue as #1158 but I see the exception is different.

Is ~/Library/Caches/py-yfinance/tkr-tz.csv actually empty?

@fredrik-corneliusson
Copy link
Contributor

fredrik-corneliusson commented Nov 14, 2022

Hi, could you verify if this fork has the same issue on M1 chip?
https://github.com/fredrik-corneliusson/yfinance-tz-cache/tree/refactor_base_py
There are not special fixes for this, just a bit bumped dependencies.

To install use:

pip install --upgrade --force-reinstall git+https://github.com/fredrik-corneliusson/yfinance-tz-cache.git@refactor_base_py

Also you can do a pip freeze and post the output from both Ubuntu and Mac.
As yfinance 0.1.* tolerates quite old libraries you could be running outdated versions on Mac even after installing the same requirements file.

@melgazar9
Copy link
Author

Hey that did not fix the issue. Here are the requirements.txt files

requirements_m1_fork.txt
requirements_m1.txt
requirements.txt

requirements_ubuntu.txt

@fredrik-corneliusson
Copy link
Contributor

Ok, thanks
As @ValueRaider suggested check if the file (a cache file) that it fails to read is empty.

You could try and remove it completely and see if it works.

Also instead of using download try to access the history directly (should at least give a smaller traceback):

t = yf.Ticker("MSFT")
t.history()

fredrik-corneliusson added a commit to fredrik-corneliusson/yfinance-tz-cache that referenced this issue Nov 15, 2022
@fredrik-corneliusson
Copy link
Contributor

The issue was not related to M1 but an empty tz-cache file.
The latest changes to https://github.com/fredrik-corneliusson/yfinance-tz-cache/tree/refactor_base_py has the fix.
Reinstall and try again.

pip install --upgrade --force-reinstall git+https://github.com/fredrik-corneliusson/yfinance-tz-cache.git@refactor_base_py

@melgazar9
Copy link
Author

Strange! It works now when I ran that pip reinstall. I don't have this issue on Ubuntu or windows so I thought it was an M1 issue! Good to close thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants