Python: install package offline with dependencies with Pip?

16,425

This question seems to have already been answered here

However, here is a quick summary:

  1. Upload your package to the Python Package Index (PyPI)
  2. Download the package using pip on a machine with internet connection, then turn the package into a .tar file

    mkdir ~/some_directory
    pip download some_package -d "~/some_directory"
    tar -cvfz some_package.tar some_directory
    
  3. Once in .tar format, you can install the package without internet connection on a machine with Python.

    tar -xzvf some_package.tar
    cd some_directory
    pip install some_package-x.x.x-py2.py3-x-x.whl -f ./ --no-index
    
Share:
16,425
hhh
Author by

hhh

Updated on June 27, 2022

Comments

  • hhh
    hhh about 2 years

    I have created a package which I can install with internet connection but I need to install it now without Internet connection so I need to download all external dependencies and install them from sources.

    How can I install Python package from sources with external packages requiring internet connection? In other words, how can I make pip to look for local sources and not external sources in the installation?

  • Ryan Codrai
    Ryan Codrai over 2 years
    In your 3rd command in step 2. the command line parameters should actually be -cvzf where the filename parameter comes last so that the next immediate parameter (which is supplied value of the filename) is interpreted correctly.