-3

I want to download some python package from Win to Linux.
I run pip download -r requirements.txt -d wheelhouse on Win10,
but it will download the win version package numpy-1.19.1-cp37-cp37m-win_amd64.whl
Can i download with linux verson of package on win.

roamer
  • 105
  • 1
  • 9
  • 1
    What do you expect the difference to be? – kaya3 Mar 24 '21 at 13:31
  • What is the point of doing this? – CATboardBETA Mar 24 '21 at 13:31
  • I suppose one reason may be that you want to build a Linux Docker container on a Windows machine and test such software. Though I would try to use the `any` distribution. In any case, the `--platform` option should do the trick. See answer below. – astrochun Mar 24 '21 at 13:41
  • https://stackoverflow.com/search?q=%5Bpip%5D+download+Linux+windows – phd Mar 24 '21 at 14:28
  • @kaya3 Binary wheels contain compiled extensions, different for every platform (processor architecture, OS, Python version, 32/64-bits). – phd Mar 24 '21 at 14:30
  • @CATboardBETA To copy the downloaded wheels to an offline host with a different architecture. – phd Mar 24 '21 at 14:30

1 Answers1

3

I'm not entirely sure why you would want to do this. By default, pip uses your local architecture so it downloads the windows files. The pip download options has a --platform option.

You can try: pip download -r requirements.txt -d wheelhouse_linux --platform manylinux1_x86_64 [--only-binary=:all: or --no-deps]

The documentation for pip download is available here with examples.

astrochun
  • 978
  • 1
  • 2
  • 11
  • "*I'm not entirely sure why you would want to do this…*" To copy the downloaded wheels to an offline host with a different architecture. – phd Mar 24 '21 at 14:25
  • "*`linux_x86_64`*" Isn't it `manylinux1_x86_64` now? – phd Mar 24 '21 at 14:28
  • I think you're right. I guess those examples are outdated. Re-adjusting answer. – astrochun Mar 24 '21 at 14:32
  • --platform require `--only-binary=:all: or --no-deps ` , download will failed when the package does not have binary version. Finally, i create the same environment to download package for offline server. – roamer Mar 25 '21 at 07:57
  • Sorry I missed that. I adjusted my answer. Glad it worked for you. – astrochun Mar 25 '21 at 13:37