Kaggle Notebooks: Installing Packages When Internet Is Off
Kaggle Notebooks can run without internet, which breaks pip installs. Learn how to check connectivity, install packages, and work within competition rules.
19 Sept 2025, 10:47 UTC

Kaggle Notebooks: Installing Packages When Internet Is Off
You fork a high-scoring Kaggle Notebook, run a cell, and see a ModuleNotFoundError. You try !pip install missing-package, but nothing happens. The useful takeaway is that Kaggle Notebooks can run with internet access disabled, especially in competitions, and package installs only work when the kernel can reach the package index.
What the Internet Toggle Controls
A Kaggle Notebook is a browser-based Jupyter environment attached to a dataset or competition. The kernel is the running Python process. In the notebook settings, there is an internet-access switch. When it is off, the kernel cannot reach PyPI or other external URLs. Competition administrators sometimes require this to prevent outside data from leaking into submissions.
When internet is on, you can install packages with a shell command in a code cell. When it is off, you are limited to libraries already installed in the base image, such as pandas, scikit-learn, and XGBoost.
Worked Example: Check Connectivity, Then Install
Open a notebook you own or have forked. In the right-hand settings panel, confirm the internet toggle position. Then run this cell:
import urllib.request
try:
with urllib.request.urlopen('https://pypi.org', timeout=5) as response:
print('Status:', response.status)
print('Internet reachable')
except Exception as error:
print('Internet check failed:', type(error).__name__, error)
Where to run: A Kaggle Notebook code cell. Permissions: You must be the notebook owner or have forked it and have edit access. Expected check: If internet is on, the cell prints status 200 and Internet reachable. If it is off, it prints a URLError or timeout. Risk: None; this is a read-only network probe.
If the check passes, install a package in the same session:
!pip install package-name
Replace package-name with the library you need. After installation finishes, verify it with:
import package_name
print(package_name.__version__)
Expected check: No ImportError, and the version prints. Risk: The installed package exists only in the current kernel session. If you restart the notebook or the container is recycled, you must install it again.
Trade-Off: Convenience vs. Competition Rules and Reproducibility
| Internet on | Internet off |
|---|---|
| Can pip install any public package | Limited to pre-installed libraries |
| Can download external data or pretrained weights | Cannot fetch outside resources during the run |
| May violate competition rules that prohibit external data | Aligns with closed-environment competition requirements |
| Makes exact reproduction harder unless you record installed versions | Easier to reproduce because the environment is fixed |
If you need a specific package and internet must stay off, download the wheel file locally, upload it to the Kaggle Notebook as a file, and install from that path:
!pip install /kaggle/working/package_name.whl
This works only if the wheel is compatible with the kernel's Python version.
Actionable Next Step
Before you copy a solution from a public notebook, run the internet check above. If the notebook uses a package not in the base image, add the install cell to your own fork and record the package name and version in a markdown cell. That way, anyone reproducing your work knows exactly what the kernel needs.
Platform behavior can change, and competition rules vary. Verify the current internet setting and rules on the competition page before relying on external packages.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.