我安装了seaborn Python包并尝试运行first tutorial,它生成了一系列错误。
我做错了什么?我将教程代码复制并粘贴到一个名为www.example.com的文件中seaborn1.py,然后点击运行,得到了这个:
/Users/apple/python/python-venv/bin/python3.12 /Users/apple/python/project1/seaborn1.py
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1344, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1319, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1365, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1314, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1074, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1018, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/http/client.py", line 1460, in connect
self.sock = self._context.wrap_socket(self.sock,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 455, in wrap_socket
return self.sslsocket_class._create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1046, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 1317, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/apple/python/project1/seaborn1.py", line 8, in <module>
tips = sns.load_dataset("tips")
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/apple/python/python-venv/lib/python3.12/site-packages/seaborn/utils.py", line 595, in load_dataset
if name not in get_dataset_names():
^^^^^^^^^^^^^^^^^^^
File "/Users/apple/python/python-venv/lib/python3.12/site-packages/seaborn/utils.py", line 522, in get_dataset_names
with urlopen(DATASET_NAMES_URL) as resp:
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 215, in urlopen
return opener.open(url, data, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 492, in _call_chain
result = func(*args)
^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1392, in https_open
return self.do_open(http.client.HTTPSConnection, req,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py", line 1347, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)>
Process finished with exit code 1
2条答案
按热度按时间vddsk6oq1#
你可以进入spotlight(搜索栏)搜索
"Install Certificates.command"
,然后按回车键。或
Macintosh HD-> Applications-> Python3.12 -> double click "Install Certificates.command"
文件8yoxcaq72#
tl;dr:您的网络堆栈安装缺少必要的根证书。
您对
sns.load_dataset("tips")
的调用尝试访问https://github.com/mwaskom/seaborn-data下的CSV,具体为https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv如果没有DigiCert TLS RSA SHA 256 2020 CA 1证书,这将不会顺利进行。
如果您使用venv、conda或poetry来获取cPython +库,这将非常顺利,而无需给予片刻的考虑。