Failed to execute 'superset load_examples ' , ssl.SSLError
I install the superset in CentOS, and when I execute the 'superset load_examples ', I have the error below:

ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)
My CentOS is under company network which can not connect the Internet. I don't know whether this cause the error. If yes, is there a way to load examples without connect Internet?
Thank you very much!
Anyone help?
Hi @sunnysnowhi - the system loads examples from the internet, unfortunately. I'm not aware of another way to load examples.
hi @willbarrett I set a proxy in /etc/profile in my CentOS , and now the server can connect internet and wget https://xxx can work properly. But when I execute superset load_examples , the error still exists, so I guess it is not the network problem...
Does anyone known how to solve it?
(superset-venv) [root@cn-north-5a-modelarts-insight superset-venv]# superset load_examples 2020-04-16 14:53:10,454:INFO:root:logging was configured successfully 2020-04-16 14:53:10,505:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'> Loading examples metadata and related data into examples Creating default CSS templates Loading energy related dataset 2020-04-16 14:53:11,738:INFO:root:Database.get_sqla_engine(). Masked URL: sqlite:////root/.superset/superset.db Traceback (most recent call last): File "/usr/local/python3/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/local/python3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/python3/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/python3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/python3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/python3/lib/python3.6/http/client.py", line 964, in send self.connect() File "/usr/local/python3/lib/python3.6/http/client.py", line 1400, in connect server_hostname=server_hostname) File "/usr/local/python3/lib/python3.6/ssl.py", line 407, in wrap_socket _context=self, _session=session) File "/usr/local/python3/lib/python3.6/ssl.py", line 814, in init self.do_handshake() File "/usr/local/python3/lib/python3.6/ssl.py", line 1068, in do_handshake self._sslobj.do_handshake() File "/usr/local/python3/lib/python3.6/ssl.py", line 689, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:777)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/superset-venv/bin/superset", line 31, in
sorry I fond my proxy was in wrong config, After fix the proxy, the problem unknown protocol is solved~~~~
Now I meet the new error: (superset-venv) [root@cn-north-5a-modelarts-insight superset-venv]# superset load_examples 2020-04-16 16:25:07,995:INFO:root:logging was configured successfully 2020-04-16 16:25:08,045:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'> Loading examples metadata and related data into examples Creating default CSS templates Loading energy related dataset 2020-04-16 16:25:09,251:INFO:root:Database.get_sqla_engine(). Masked URL: sqlite:////root/.superset/superset.db Traceback (most recent call last): File "/usr/local/python3/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/usr/local/python3/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/python3/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/python3/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/python3/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/usr/local/python3/lib/python3.6/http/client.py", line 964, in send self.connect() File "/usr/local/python3/lib/python3.6/http/client.py", line 1400, in connect server_hostname=server_hostname) File "/usr/local/python3/lib/python3.6/ssl.py", line 407, in wrap_socket _context=self, _session=session) File "/usr/local/python3/lib/python3.6/ssl.py", line 814, in init self.do_handshake() File "/usr/local/python3/lib/python3.6/ssl.py", line 1068, in do_handshake self._sslobj.do_handshake() File "/usr/local/python3/lib/python3.6/ssl.py", line 689, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/superset-venv/bin/superset", line 31, in
I found the solution!
vim /opt/superset-venv/lib/python3.6/site-packages/superset/examples/helpers.py and change the way of urlopen:
before change: content = request.urlopen(f"{BASE_URL}{filepath}?raw=true").read()
after change: import ssl context = ssl._create_unverified_context() content = request.urlopen(f"{BASE_URL}{filepath}?raw=true", context=context).read()

The error above disappear, yeah~
@sunnysnowhi The code has been changed in the latest version, but there is still this error, I do not know how to modify the code in the aspect of code formation, please advise, the code is as follows:
import json import os from typing import Any
from superset import app, db from superset.connectors.sqla.models import SqlaTable from superset.models.slice import Slice
BASE_URL = "https://github.com/apache-superset/examples-data/blob/master/"
misc_dash_slices: set[str] = set() # slices assembled in a 'Misc Chart' dashboard
def get_table_connector_registry() -> Any: return SqlaTable
def get_examples_folder() -> str: return os.path.join(app.config["BASE_DIR"], "examples")
def update_slice_ids(pos: dict[Any, Any]) -> list[Slice]: """Update slice ids in position_json and return the slices found.""" slice_components = [ component for component in pos.values() if isinstance(component, dict) and component.get("type") == "CHART" ] slices = {} for name in {component["meta"]["sliceName"] for component in slice_components}: slc = db.session.query(Slice).filter_by(slice_name=name).first() if slc: slices[name] = slc for component in slice_components: slc = slices.get(component["meta"]["sliceName"]) if slc: component["meta"]["chartId"] = slc.id component["meta"]["uuid"] = str(slc.uuid) return list(slices.values())
def merge_slice(slc: Slice) -> None: o = db.session.query(Slice).filter_by(slice_name=slc.slice_name).first() if o: db.session.delete(o) db.session.add(slc) db.session.commit()
def get_slice_json(defaults: dict[Any, Any], **kwargs: Any) -> str: defaults_copy = defaults.copy() defaults_copy.update(kwargs) return json.dumps(defaults_copy, indent=4, sort_keys=True)
def get_example_url(filepath: str) -> str: return f"{BASE_URL}{filepath}?raw=true"