gpt4 book ai didi

Python YahooFinancials 结合 mysql 连接器导致 SSL 错误

转载 作者:太空宇宙 更新时间:2023-11-03 14:31:32 24 4
gpt4 key购买 nike

我有以下代码

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 脚本中工作。

最佳答案

对于那些面临同样问题的人,我找到了解决方案。只需更改导入的顺序即可。首先导入 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()

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

关于Python YahooFinancials 结合 mysql 连接器导致 SSL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52413285/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com