[Python] Installing python package from zip file offline

Discussão em 'Python' iniciado por Stack, Setembro 4, 2025.

  1. Stack

    Stack Membro Participativo

    I am working in Kaggle notebook. I need to install transformers package offline. Normally I would install it like this (online):

    !pip install git+https://github.com/huggingface/transformers


    Here is what I did to accomplish the same, but offline.

    I created snapshot of installed packages before and after installation of transformers.

    !pip freeze > requirements_b.txt
    !pip install git+https://github.com/huggingface/transformers
    !pip freeze > requirements_a.txt


    The difference between them is

    huggingface-hub==0.34.4
    git+https://github.com/huggingface/transformers@e39f2220969d5ee2fe5643eef4888e36b6800a3c
    tokenizers==0.22.0


    I downloaded the above packages locally with

    !pip download huggingface-hub==0.34.4 tokenizers==0.22.0 -d ./wheels --verbose
    !pip download git+https://github.com/huggingface/transformers -d ./wheels


    I factory reset kernel and tried to install everything offline:

    !pip install huggingface-hub==0.34.4 tokenizers==0.22.0 \
    -U --no-index --find-links /kaggle/working/wheels


    but below command generated error:

    !pip install wheels/transformers-4.57.0.dev0.zip --verbose


    Error message:

    Using pip 24.1.2 from /usr/local/lib/python3.11/dist-packages/pip (python 3.11)
    Processing ./wheels/transformers-4.57.0.dev0.zip
    Running command pip subprocess to install build dependencies
    Using pip 24.1.2 from /usr/local/lib/python3.11/dist-packages/pip (python 3.11)
    Non-user install by explicit request
    Created build tracker: /tmp/pip-build-tracker-9vzem4u4
    Entered build tracker: /tmp/pip-build-tracker-9vzem4u4
    Created temporary directory: /tmp/pip-install-5g1aenu5
    Created temporary directory: /tmp/pip-ephem-wheel-cache-bnhq0fx_
    1 location(s) to search for versions of setuptools:
    * https://pypi.org/simple/setuptools/
    Fetching project page and analyzing links: https://pypi.org/simple/setuptools/
    Getting page https://pypi.org/simple/setuptools/
    Found index url https://pypi.org/simple/
    Looking up "https://pypi.org/simple/setuptools/" in the cache
    Request header has "max_age" as 0, cache bypassed
    No cache entry available
    Starting new HTTPS connection (1): pypi.org:443
    Incremented Retry for (url='/simple/setuptools/'): Retry(total=4, connect=None, read=None, redirect=None, status=None)
    WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd0335f6c10>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
    Starting new HTTPS connection (2): pypi.org:443
    Incremented Retry for (url='/simple/setuptools/'): Retry(total=3, connect=None, read=None, redirect=None, status=None)
    WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd0335f7e50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
    Starting new HTTPS connection (3): pypi.org:443
    Incremented Retry for (url='/simple/setuptools/'): Retry(total=2, connect=None, read=None, redirect=None, status=None)
    WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd03348a550>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
    Starting new HTTPS connection (4): pypi.org:443
    Incremented Retry for (url='/simple/setuptools/'): Retry(total=1, connect=None, read=None, redirect=None, status=None)
    WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd0335f6fd0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
    Starting new HTTPS connection (5): pypi.org:443
    Incremented Retry for (url='/simple/setuptools/'): Retry(total=0, connect=None, read=None, redirect=None, status=None)
    WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd033488910>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/setuptools/
    Starting new HTTPS connection (6): pypi.org:443
    Could not fetch URL https://pypi.org/simple/setuptools/: connection error: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/setuptools/ (Caused by NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd0334a0b50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')) - skipping
    Skipping link: not a file: https://pypi.org/simple/setuptools/
    Given no hashes to check 0 links for project 'setuptools': discarding no candidates
    ERROR: Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)
    ERROR: No matching distribution found for setuptools>=40.8.0
    Exception information:
    Traceback (most recent call last):
    File "/usr/local/lib/python3.11/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
    File "/usr/local/lib/python3.11/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 174, in _add_to_criteria
    raise RequirementsConflicted(criterion)
    pip._vendor.resolvelib.resolvers.RequirementsConflicted: Requirements conflict: SpecifierRequirement('setuptools>=40.8.0')

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "/usr/local/lib/python3.11/dist-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
    ^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/dist-packages/pip/_vendor/resolvelib/resolvers.py", line 399, in resolve
    raise ResolutionImpossible(e.criterion.information)
    pip._vendor.resolvelib.resolvers.ResolutionImpossible: [RequirementInformation(requirement=SpecifierRequirement('setuptools>=40.8.0'), parent=None)]

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
    File "/usr/local/lib/python3.11/dist-packages/pip/_internal/cli/base_command.py", line 179, in exc_logging_wrapper
    status = run_func(*args)
    ^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/dist-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
    ^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/dist-packages/pip/_internal/commands/install.py", line 377, in run
    requirement_set = resolver.resolve(
    ^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.11/dist-packages/pip/_internal/resolution/resolvelib/resolver.py", line 104, in resolve
    raise error from e
    pip._internal.exceptions.DistributionNotFound: No matching distribution found for setuptools>=40.8.0
    Removed build tracker: '/tmp/pip-build-tracker-9vzem4u4'
    error: subprocess-exited-with-error

    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip.
    full command: /usr/bin/python3 /usr/local/lib/python3.11/dist-packages/pip/__pip-runner__.py install --ignore-installed --no-user --prefix /tmp/pip-build-env-3nmv0d45/overlay --no-warn-script-location -vv --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0'
    cwd: [inherit]
    Installing build dependencies ... error
    error: subprocess-exited-with-error

    × pip subprocess to install build dependencies did not run successfully.
    │ exit code: 1
    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip.


    It looks like it is trying to connect to internet. Is there way to solve it?

    Continue reading...

Compartilhe esta Página