Python和mysql连接器的结合导致了SSL

2024-05-18 07:33:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下代码

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在另一个python脚本中工作,没有YahooFinancials。你知道吗


Tags: 代码fromimportconnectorstockmysqlerroryahoo
1条回答
网友
1楼 · 发布于 2024-05-18 07:33:14

对于那些面临同样问题的人,我找到了解决办法。只要改变进口的顺序。首先导入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()

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

相关问题 更多 >