-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
ImportError using yf.Ticker #1751
Comments
What version |
0.4.12 |
|
Should i download a prior version that worked? If so, which one do u recommend? Thanks |
|
@ValueRaider
so you don't need import at lines 75-76 |
|
So maybe use |
Fix will be setting minimum version of |
Hello. Hope everyone is doing well. Getting an error after upgraded yfinance today (11/28/23) with the following code
%pip install yfinance --upgrade --no-cache-dir --pre
.I am using python version 3.10 and yfinance version 02.32
Error I am getting is as follows:
ImportError: cannot import name 'DO_NOT_CACHE' from 'requests_cache' (C:\Users\17147\anaconda3\envs\ib230729\Lib\site-packages\requests_cache_init_.py)
Simple code that reproduces the problem:
session = requests_cache.CachedSession('yfinance.cache')
session.headers['User-agent'] = 'my-program/1.0'
msft = yf.Ticker('msft', session=session)
msft.actions
Traceback below:
ImportError Traceback (most recent call last)
Cell In[2], line 3
1 session = requests_cache.CachedSession('yfinance.cache')
2 session.headers['User-agent'] = 'my-program/1.0'
----> 3 msft = yf.Ticker('msft', session=session)
File ~\anaconda3\envs\ib230729\Lib\site-packages\yfinance\ticker.py:34, in Ticker.init(self, ticker, session)
33 def init(self, ticker, session=None):
---> 34 super(Ticker, self).init(ticker, session=session)
35 self._expirations = {}
36 self._underlying = {}
File ~\anaconda3\envs\ib230729\Lib\site-packages\yfinance\base.py:71, in TickerBase.init(self, ticker, session)
68 if utils.is_isin(self.ticker):
69 self.ticker = utils.get_ticker_by_isin(self.ticker, None, session)
---> 71 self._data: YfData = YfData(session=session)
73 self._analysis = Analysis(self._data, ticker)
74 self._holders = Holders(self._data, ticker)
File ~\anaconda3\envs\ib230729\Lib\site-packages\yfinance\data.py:47, in SingletonMeta.call(cls, *args, **kwargs)
45 with cls._lock:
46 if cls not in cls._instances:
---> 47 instance = super().call(*args, **kwargs)
48 cls._instances[cls] = instance
49 else:
File ~\anaconda3\envs\ib230729\Lib\site-packages\yfinance\data.py:75, in YfData.init(self, session)
70 else:
71 # Is caching. This is annoying.
72 # Can't simply use a non-caching session to fetch cookie & crumb,
73 # because then the caching-session won't have cookie.
74 self._session_is_caching = True
---> 75 from requests_cache import DO_NOT_CACHE
76 self._expire_after = DO_NOT_CACHE
77 self._crumb = None
ImportError: cannot import name 'DO_NOT_CACHE' from 'requests_cache' (C:\Users\17147\anaconda3\envs\ib230729\Lib\site-packages\requests_cache_init_.py)
The text was updated successfully, but these errors were encountered: