hhh
hhh

Reputation: 52840

Python: install package offline with dependencies with Pip?

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?

Upvotes: 3

Views: 23195

Answers (1)

John Laboe
John Laboe

Reputation: 146

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
    

Upvotes: 13

Related Questions