Repository navigation
Closed
Labels
Description
Describe the bug
When trying to load the dataset I get an error.
Steps/Code to Reproduce
from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
housing = fetch_california_housing()
X_train_full, X_test, y_train_full, y_test = train_test_split(
housing.data, housing.target)
X_train, X_valid, y_train, y_valid = train_test_split(X_train_full, y_train_full)
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_valid_scaled = scaler.transform(X_valid)
X_test_scaled = scaler.transform(X_test)
Expected Results
Dataset loads
Actual Results
HTTPError Traceback (most recent call last)
[/var/folders/wx/mz49j6yd5514yjn5k60sk6900000gn/T/ipykernel_16344/1379907178.py](https://file+.vscode-resource.vscode-cdn.net/var/folders/wx/mz49j6yd5514yjn5k60sk6900000gn/T/ipykernel_16344/1379907178.py) in <module>
3 from sklearn.preprocessing import StandardScaler
4
----> 5 housing = fetch_california_housing()
6
7 X_train_full, X_test, y_train_full, y_test = train_test_split(
[~/opt/anaconda3/lib/python3.9/site-packages/sklearn/datasets/_california_housing.py](https://file+.vscode-resource.vscode-cdn.net/Users/aryamanbhatia/neural%20network%20for%20practice/~/opt/anaconda3/lib/python3.9/site-packages/sklearn/datasets/_california_housing.py) in fetch_california_housing(data_home, download_if_missing, return_X_y, as_frame)
133 This dataset consists of 20,640 samples and 9 features.
134 """
--> 135 data_home = get_data_home(data_home=data_home)
136 if not exists(data_home):
137 makedirs(data_home)
[~/opt/anaconda3/lib/python3.9/site-packages/sklearn/datasets/_base.py](https://file+.vscode-resource.vscode-cdn.net/Users/aryamanbhatia/neural%20network%20for%20practice/~/opt/anaconda3/lib/python3.9/site-packages/sklearn/datasets/_base.py) in _fetch_remote(remote, dirname)
[~/opt/anaconda3/lib/python3.9/urllib/request.py](https://file+.vscode-resource.vscode-cdn.net/Users/aryamanbhatia/neural%20network%20for%20practice/~/opt/anaconda3/lib/python3.9/urllib/request.py) in urlretrieve(url, filename, reporthook, data)
237 url_type, path = _splittype(url)
238
--> 239 with contextlib.closing(urlopen(url, data)) as fp:
240 headers = fp.info()
241
...
--> 641 raise HTTPError(req.full_url, code, msg, hdrs, fp)
642
643 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 403: Forbidden
Versions
System:
python: 3.9.13 (main, Aug 25 2022, 18:29:29) [Clang 12.0.0 ]
executable: /Users/aryamanbhatia/opt/anaconda3/bin/python
machine: macOS-10.16-x86_64-i386-64bit
Python dependencies:
pip: 22.2.2
setuptools: 63.4.1
sklearn: 1.0.2
numpy: 1.26.3
scipy: 1.9.1
Cython: 0.29.32
pandas: 1.4.4
matplotlib: 3.5.2
joblib: 1.1.0
threadpoolctl: 2.2.0
Built with OpenMP: TrueReacted by Insaf Ashrapov, Alexey Morozov and Karso
Activity
glemaitre commentedon Jan 28, 2024
I cannot reproduce. Either it was something transient or it is on your network side.
minkhantDoctoral commentedon May 13, 2024
I got the same error on Google Colab too. Someone said this bug occurs very frequent. Sometime it works, sometime it doesn't. Is there any solution to it?
AsierMM commentedon May 14, 2024
I tried yo change the account and it worked. If you change the account that you are working with and try the same code it should be fine.
tdtu98 commentedon May 25, 2024
Got the same error, don't know how to fix it.
Diyago commentedon May 25, 2024
same, seems no fix half year(
Diyago commentedon May 25, 2024
lemeb commentedon May 27, 2024
Same here! (Based in France FYI, but using Colab)
mateors6 commentedon Jun 7, 2024
I got the same problem in Spain, using Colab. But if I run it on Spyder it works fine!
glemaitre commentedon Jun 7, 2024
I'm reopening this issue because we have too many reported issues.
glemaitre commentedon Jun 7, 2024
I would propose to store the dataset directly on OpenML and call
fetch_openmlinternally.lesteve commentedon Jun 7, 2024
I was able to reproduce the HTTP 403 inside Colab. Note this is not only
fetch_california_housingbut all scikit-learn datasets on Figshare, sofetch_covtype,fetch_rcv1, etc ...I am wondering if Figshare is not blocking some IP address, the HTTP 403 Forbidden is a bit unexpected ...
Retrying a few times, it seems to be quite consistent, i.e. if you keep retrying the problem does not go away.
17 remaining items
gigit0000 commentedon Jun 16, 2024
It's strange - the code runs perfectly on Colab but fails on Kaggle, at the same time even on the same local machine. Maybe this info can help troubleshoot the issue.
Abdullah-R commentedon Jun 17, 2024
If you're experiencing this on Google Colab, the error seems to disappear if you switch to a TPU runtime (different servers hosting I guess?).
lesteve commentedon Jun 18, 2024
I think this is a similar work-around as disconnecting the runtime mentioned in #28297 (comment) although a wild-guess could be that the TPU servers have less chance to be blocked (at least for now)?
lesteve commentedon Jun 18, 2024
I tried on Kaggle notebooks and it seems like indeed the problem happens from time to time. The work-around is to click on the power button (Stop session), reexecute the code (you will get a different IP address) and cross your fingers 🤞, make sure you have internet enabled as well (just in case).
The debugging command I used is the following one, which downloads the file needed for California housing:
Here is a screenshot where it did not work (HTTP 403)

Here is a screenshot where it did work (HTTP 200):

gigit0000 commentedon Jun 18, 2024
@lesteve Thanks for your comment. Yes, that's exactly what I did. I just reported to possibly help troubleshoot this issue :)
lesteve commentedon Jun 19, 2024
Some kind of summary comment:
gigit0000 commentedon Jun 20, 2024
@lesteve Thank you!
Add the data, in case of connection problems (403 for some sklearn da…
lesteve commentedon Jul 3, 2024
I got an answer from Figshare support saying that they fixed the issue. I tried roughly 10 times on Colab and the same on Kaggle notebooks and I was not able to reproduce the issue 🎉.
I am going to close this one, if you encounter the issue again please comment in this issue!
You can also try the documented work-arounds in #28297 (comment) and mention in case that does not fix the issue.
gigit0000 commentedon Jul 4, 2024
@lesteve Great support - thank you!!!
khyarih commentedon Dec 30, 2025
Got the same Forbidden error today, i'm using a linux server tried to use some VPNs but didn't work
lesteve commentedon Dec 31, 2025
See #32961 this is a known issue on the Figshare side. There is not much we can do unfortunately.
Please refrain from commenting on old closed issues 🙏.
worldart commentedon Jan 5, 2026
Same error on GoogleColab and my local computer.
Code:
Below is the error.