we are trying to install couple of python packages without internet.
For ex : python-keystoneclient
For that we have the packages downloaded from https://pypi.python.org/pypi/python-keystoneclient/1.7.1 and kept it in server.
However, while installing tar.gz and .whl packages , the installation is looking for dependent packages to be installed first. Since there is no internet connection in the server, it is getting failed.
For ex : For python-keystoneclient we have the following dependent packages
stevedore (>=1.5.0)
six (>=1.9.0)
requests (>=2.5.2)
PrettyTable (<0.8,>=0.7)
oslo.utils (>=2.0.0)
oslo.serialization (>=1.4.0)
oslo.i18n (>=1.5.0)
oslo.config (>=2.3.0)
netaddr (!=0.7.16,>=0.7.12)
debtcollector (>=0.3.0)
iso8601 (>=0.1.9)
Babel (>=1.3)
argparse
pbr (<2.0,>=1.6)
When i try to install packages one by one from the above list, once again its looking for nested dependency .
Is there any way we could list ALL the dependent packages for installing a python module like python-keystoneclient.
pipdeptree
is a command line utility for displaying the python packages installed in an virtualenv in form of a dependency tree. Just use it: https://github.com/naiquevin/pipdeptreeThis is how I handle this case:
On the machine where I have access to Internet:
Then move the tar file to the destination machine that does not have Internet access and perform the following:
If you want to install a bunch of dependencies from, say a requirements.txt, you would do:
And, once you transfer the dependencies.tar.gz to the machine which does not have internet you would do:
We have a similar situation at work, where the production machines have no access to the Internet; therefore everything has to be managed offline and off-host.
Here is what I tried with varied amounts of success:
basket
which is a small utility that you run on your internet-connected host. Instead of trying to install a package, it will instead download it, and everything else it requires to be installed into a directory. You then move this directory onto your target machine. Pros: very easy and simple to use, no server headaches; no ports to configure. Cons: there aren't any real showstoppers, but the biggest one is that it doesn't respect any version pinning you may have; it will always download the latest version of a package.Run a local pypi server. Used
pypiserver
anddevpi
.pypiserver
is super simple to install and setup;devpi
takes a bit more finagling. They both do the same thing - act as a proxy/cache for the real pypi and as a local pypi server for any home-grown packages.localshop
is a new one that wasn't around when I was looking, it also has the same idea. So how it works is your internet-restricted machine will connect to these servers, they are then connected to the Internet so that they can cache and proxy the actual repository.The problem with the second approach is that although you get maximum compatibility and access to the entire repository of Python packages, you still need to make sure any/all dependencies are installed on your target machines (for example, any headers for database drivers and a build toolchain). Further, these solutions do not cater for non-pypi repositories (for example, packages that are hosted on github).
We got very far with the second option though, so I would definitely recommend it.
Eventually, getting tired of having to deal with compatibility issues and libraries, we migrated the entire circus of servers to commercially supported docker containers.
This means that we ship everything pre-configured, nothing actually needs to be installed on the production machines and it has been the most headache-free solution for us.
We replaced the pypi repositories with a local docker image server.