0

I want to install packages on a computer which does not have internet (connect via ssh) from a computer which does.

My idea is that instead of uploading the individual pip packages for each project + python version (same reasons why you'd want to use a virtual environment), I'd like to install the target package in an empty virtual environment on the machine with internet access and then scp all dependencies from my_env/lib/python3.6/site-packages to the remote machine.

Then I'd pip install from there.

Ideal scenario:

Machine with internet

$ python -m venv my_env
$ source ./my_env/bin/activate
(my_env) $ pip install lime

Then send my_env/lib/python3.6/site-packages to the remote machine (let's name itsource_packages/)

Machine without internet

$ sudo pip install lime --find-everything-in ./source_packages

I have tried

pip install lime --no-index --find-links path/to/my_env/lib/python3.6/site-packages/

But this raises an error:

Collecting lime

Could not find a version that satisfies the requirement lime (from >versions: ) No matching distribution found for lime

EDIT

The proposed solutions (see comments) are close to working except I have platform compatibility issues. Internet machine is a Mac, remote server is CentOS.

I'm therefore afraid that unzipping site-packages/ in the server's lib/python3.6/ directory would fail in some cases.

Regarding the pip download solution, it is also partial as default behavior is to download according to current platform but the --platform flag only works with binaries. A package as lime can't therefore be downloaded specifying the platform.

A workaround would be to be able to run something in the likes of

pip download --only-binary=:all: --platform=linux_x86_64 lime

but with a fallback to download the source if the binary asked for is not available

ted
  • 13,596
  • 9
  • 65
  • 107
  • how about simply unzipping the package in your remote `/site-packages/` directory? I haven't tested but it might just be enough to use the package – pills Mar 12 '18 at 16:31
  • @pills that would work for a standalone package, I could even use pip install without putting it in site-packages/ but if the package has dependencies which have dependencies I find myself iterating dozens of times : 1/download the wheel 2/ push it to the remote machine 3/pip install from the wheel 4/retry pip install 5/if fail, go to 1/ – ted Mar 12 '18 at 16:38
  • 1
    Use pip to download all the requirements, as in [this answer](https://stackoverflow.com/a/14447068/). – Alasdair Mar 12 '18 at 16:41
  • 2
    perhaps my first comment was not clear; what you could do is install everything (inc. dependencies) on source machine, zip the entire /site-packages/, scp it and unzip it in the correct folder of your destination machine. My main point is that AFAIK, once all the files are in the Python path it should Just Work. – pills Mar 12 '18 at 16:44
  • ok I see what you mean. Good points. I'll try both ideas I think they should work. Cheers – ted Mar 12 '18 at 16:44
  • @pills I've updated the question – ted Mar 12 '18 at 17:27
  • @Alasdair also if you have a suggestion – ted Mar 12 '18 at 17:28
  • Possible duplicate of [Installing Django and related packages on an offline computer](https://stackoverflow.com/questions/34704163/installing-django-and-related-packages-on-an-offline-computer) – phd Mar 12 '18 at 21:40
  • @phd I partly agree, but the platform issue is not addressed in the mentioned answer – ted Mar 12 '18 at 22:35
  • The question has been asked many times and the answer is still [no](https://stackoverflow.com/a/48925926/7976758). – phd Mar 13 '18 at 01:10
  • You could use a virtual machine or container to download the requirements or build wheels. – Alasdair Mar 13 '18 at 09:36

0 Answers0