【问题标题】:Python YahooFinancials in combination with mysql connector lead to SSL errorPython YahooFinancials 与 mysql 连接器结合导致 SSL 错误
【发布时间】:2018-09-19 19:51:11
【问题描述】:

我有以下代码

from mysql.connector import MySQLConnection, Error
from yahoofinancials import YahooFinancials

yahoo_financials = YahooFinancials('AAPL')
historical_stock_prices = yahoo_financials.get_prev_close_price()

此代码导致以下错误消息:

OSError: [Errno socket error] [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

代码在不导入 MySQLConnection 的情况下运行良好,但我稍后需要 MySQLConnection。此外,在我的机器上,MySQLConnection 在另一个没有 YahooFinancials 的 python 脚本中工作。

【问题讨论】:

    标签: python ssl ssl-certificate yahoo-finance mysqlconnection


    【解决方案1】:

    对于那些面临同样问题的人,我找到了解决方案。只需更改导入的顺序。首先导入 YahooFinancials,然后导入 MySQLConnection:

    from yahoofinancials import YahooFinancials
    from mysql.connector import MySQLConnection, Error
    
    yahoo_financials = YahooFinancials('AAPL')
    historical_stock_prices = yahoo_financials.get_prev_close_price()
    

    但不幸的是,我不知道为什么会这样。

    【讨论】:

      猜你喜欢
      • 2019-06-26
      • 2019-06-05
      • 2014-01-14
      • 2019-07-25
      • 2013-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-21
      相关资源
      最近更新 更多