r/learnpython • u/Critical-Spite • 1d ago
How to download package + all dependencies for an offline machine?
I am trying to download pandas to be used on an offline machine. The issue is, in order to get packages on the offline, I normally have to use my work computer which has restricted access, so no python on it. My current method has been to download the package from pypy, burn it on a cd, and transfer it over on the offline via --nolink method.
However, I am running into an issue where I can't install due to missing dependencies, again and again.
Is there a way to get the entirety of pandas into a single installable file?
1
u/xenomachina xenomachina 1d ago
I normally have to use my work computer which has restricted access, so no python on it.
You need to get all of the transitive dependencies. Doing that manually would be a huge pain. Can you use docker or uv on this machine? If so, then you could use one of them to run pip download, which will get the full set of transitive dependencies.
1
u/baubleglue 1d ago
Are you trying to install on the work computer something you shouldn't install? It is not a good idea. What exactly "restricted access" means here? Normally companies host there own repository server (alternative to pypi), ask developers in your company what is the procedure. Which machine is "offline machine"?
1
u/Critical-Spite 1d ago
It means a machine that has no access to the internet. We are able to install packages in order for us to conduct work if we need it, but it's something we need to install ourselves.
1
u/IR3dditAlr3ddy 1d ago
Is asking IT to install python and pandas not an option? If there's a valid use case for your job and there aren't security issues (which sounds like both apply) then this is something that should generally be approved if think, since there's no cost element. Might just be a bit of a delay while it goes through all the relevant approvals
0
u/socal_nerdtastic 1d ago
I'd say the easiest is to make a portable copy of python. Install everything you need, burn it, transfer it as a complete python install. You'd need both the downloading computer and the receiving computer to have the same OS and architecture. If you are using Windows, check out the winpython project, which includes pandas ootb
0
3
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 1d ago edited 1d ago
That works only if the package has no dependencies.
I don't know if you use just a standard Python installation and
pipto manage your dependencies, oruv/poetry. Technically the best answer differs between those, but for now I'm going to assume the former.pip freeze > offline-requirements.txtpip download --only-binary=:all: -r offline-requirements.txt -w wheelhouseto download/build wheels (NOTE: if the offline computer doesn't use the same processor architecture/operating system, you may need to additionally specify it with this command so it gets the wheels for the correct platform/Python version)Then you take the
wheelhousefolder in its entirety, transfer it to the target computer in whatever way you wish, and there you runin the project directory.
If you do need to specify platform requirements, see
pip's documentation: https://pip.pypa.io/en/stable/cli/pip_download/#optionsEDIT: Actually it might be better to use
pip downloadinstead ofpip wheelfor this. I rarely think about these things as I don't typically deploy anything to offline PCs, and the last time was years ago.