我正在从一个非常简单的代码中调用yahoo_fin.options.get_expiration_dates()
,这样就不太可能加载相同名称的其他模块。
我的整个代码是这样的:
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")
最后一行的输出是:
NameError: name 'HTMLSession' is not defined
您能帮我了解发生了什么吗?
答案 0 :(得分:4)
yahoo_fin的一些功能(包括yahoo_fin.options.get_expiration_dates
方法)需要request-html。您可以使用pip安装它(需要Python 3.6 +):
pip install requests-html
安装后,您需要重新启动Python会话。 This link提供有关哪些功能需要request-html的信息。