3

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?

hhh
  • 50,788
  • 62
  • 179
  • 282
  • You can't just install the dependencies in order? I mean it seems like which ever solution you find you'll have to figure out which packages you need and download them. So is it extra work to just install them in the right order, or is there some other problem? – sehafoc Aug 13 '18 at 20:52
  • Possible duplicate of [Python Packages Offline Installation](https://stackoverflow.com/questions/11091623/python-packages-offline-installation) – phd Aug 14 '18 at 20:15

1 Answers1

13

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
    
John Laboe
  • 146
  • 1
  • 2
  • 2
    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. – Ryan Codrai Oct 12 '21 at 13:17
  • for python 3.11 in 3th steps, can simply: – Ro Ma Nov 08 '22 at 15:56