머신러닝) 핸즈온 머신러닝 2판 2장 파이선 3.9 오류 해결
핸즈온 머신러닝 2판에서 2장에 데이터를 받아오는 fetch_housing_data()라는 함수가 있는데 파이선 3.9에
서 실행시 SSLCertVerificationError가 발생합니다.
이 문제를 해결하기 위해서 default ssl context를 정의해주면 쉽게 해결 됩니다.
<수정 코드>
1 2 3 4 5 6 7 8 | def fetch_housing_data(housing_url=HOUSING_URL, housing_path=HOUSING_PATH): os.makedirs(housing_path, exist_ok=True) tgz_path = os.path.join(housing_path, "housing.tgz") ssl._create_default_https_context = ssl._create_unverified_context #추가 urllib.request.urlretrieve(housing_url, tgz_path) housing_tgz = tarfile.open(tgz_path) housing_tgz.extractall(path=housing_path) housing_tgz.close() | cs |
위와 같이 빨간 줄의 코드 한 줄만 추가 시켜주면 정상작동합니다.
감사합니다:)
댓글 없음: