I'm calling yahoo_fin.options.get_expiration_dates()
from a very simple code, such that it's unlikely that I have loaded other modules with the same name.
My whole code is this:
import matplotlib.pyplot as plt
import pandas as pd
from numpy import *
from yahoo_fin import options
plt.style.use("seaborn")
expirationDates = options.get_expiration_dates("goog")
The output of the last line is:
NameError: name 'HTMLSession' is not defined
Can you help me understand what's going on?
yahoo_fin requires requests-html for a few of its functions, including the yahoo_fin.options.get_expiration_dates
method. You can install it using pip (it requires Python 3.6+):
pip install requests-html
Once installed, you need to restart your Python session. This link provides information on what functionality requires requests-html.