haruki
August 2, 2022, 7:59am
1
Our servers are based in mainland China, and when I download the python package:
Step 40/51 : RUN ${KERNEL_PYTHON_PREFIX}/bin/pip install --no-cache-dir -r “requirements.txt”
—> Running in f39e8d0e05c1
Collecting numpy
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘ConnectTimeoutError(<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f6bf37e6490>, ‘Connection to files.pythonhosted.org timed out. (connect timeout=15)’)’: /packages/86/c9/9f9d6812fa8a031a568c2c1c49f207a0a4030ead438644c887410fc49c8a/numpy-1.23.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Downloading numpy-1.23.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.1 MB)
github: GitHub - harukimisola/test: test
config.yaml:
config:
BinderHub:
use_registry: true
image_prefix: “registry.cn-hangzhou.aliyuncs.com/haruki/demo- ”
hub_url: “http://47.100.222.154 ”
How do I solve the timeout problem? Thanks for any help
manics
August 2, 2022, 11:48am
2
Was this a temporary failure due to the remote server being inaccessible- if so retrying after a few hours usually fixes things. Or does it always happen?
1 Like
haruki
August 3, 2022, 2:02am
4
Thank you for your reply!
This is not a temporary faliure, I’ve tried many times. And the downloading problem is common in here. It is usually not feasible to download directly from the official website using pip, we usually download the package of python in our image source.
I thought I should modify the download source in the config.yaml, but I don’t know how to write this code.
haruki
August 3, 2022, 8:11am
5
I modified the installation source of the python package in the requirement.txt and it is now available for download. Like this:
numpy
to http://pypi.doubanio.com/packages/f5/40/e312a465ec493e1f3a1bfe5bd535be517ec60fa380f0bd061f8c66b420ab/numpy-1.10.3-cp26-cp26m-manylinux1_x86_64.whl#sha256=9c17ce20d9bdf186f440a256bc29bd182de6725f003610325985c67a24f98f43
Each package needs to go to the image website to find the corresponding download link, although it is troublesome, but it can work.
manics
August 3, 2022, 11:07am
6
BinderHub internally uses repo2docker to build containers. repo2docker essentially generates a Dockerfile from a template, and builds an image from it. For example this is where the pip install ... requirements.txt
is generated:
),
)
)
# install requirements.txt in the kernel env
requirements_file = self.binder_path("requirements.txt")
if os.path.exists(requirements_file):
scripts.append(
(
"${NB_USER}",
'{} install --no-cache-dir -r "{}"'.format(pip, requirements_file),
)
)
return scripts
@property
def _should_preassemble_pip(self):
"""Peek in requirements.txt to determine if we can assemble from only env files
If there are any local references, e.g. `-e .`,
stage the whole repo prior to installation.
According to this StackOverflow answer you can create a configuration file for pip.
BinderHub uses a configurable repo2docker image
build_image = Unicode(
"quay.io/jupyterhub/repo2docker:2022.02.0",
help="""
The repo2docker image to be used for doing builds
""",
config=True,
)
so you could maybe extend the default image with a pip configuration file?
1 Like
haruki
August 5, 2022, 3:26am
7
Thanks for your selfless help, it was very useful!
1 Like