python pip install local files

I have a large Python file repository - and I want to install a module (in this case Faker)

pip install ./Faker

Pip starts but as it needs six and six needs something else it tries to connect to the web. But of course this fails as I am on a intranet.

Local Only

This forces local resolution

pip install --no-index --find-links=. <Package>

Get Current Python Env, and download the source packages

Do get the current config

pip freeze

Now to remove the version

pip freeze | cut -d '=' -f 1

To place these all on 1 line - use the awesome tr function.

 pip freeze | cut -d '=' -f 1 | tr '\n' ' '

Now use this "string" in a pip download

pip download $(pip freeze | cut -d '=' -f 1 | grep -o -v package-to-ignore | tr '\n' ' ')

Pip Download Source Packages

To run a python load offline you need the packages..

This is a handy-script that should allow the neutral (i.e. not Mac on Linux only) packages to be downloaded with their dependancies.

pip download \
    --only-binary=:all: \
    --platform any \
    --python-version 3 \
    --implementation py \
    --abi none \

Using it with the freeze combo would look a little like this

for package in $(pip freeze | cut -d '=' -f 1 | grep -o -v package-to-ignore | tr '\n' ' ')
   echo "Downloading $package" 
   pip download \
    --only-binary=:all: \
    --platform any \
    --python-version 3 \
    --implementation py \
    --abi none \


Offline Installing

With packages installed, you now should be able to install using

bash $ pip install --no-index --find-links=/local/dir/ SomePackage-