0

I'd like to specify which directory pip install downloads the file to because I'm getting this error when installing torch:

ERROR: Could not install packages due to an EnvironmentError: [Errno 28] No space left on device
[...]
RuntimeError: Couldn't install torch.
Command: "/home/.../bin/python3" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 1

So I tried "/media/.../python3" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118 -t "/directory/" but it still downloads to the root drive of my Debian11/KDE machine. Didn't find the solution in the pip documentation. How can I change where it downloads to?

This package has a size of multiple GBs, has really nobody thought of enabling users to specify where it should be downloaded to? Or is using a symbolic link for the cache dir the only way to do this?

mYnDstrEAm
  • 751
  • 2
  • 8
  • 26
  • 1
    `--target` is about the installation directory. For downloads you might want to check [caching settings](https://pip.pypa.io/en/stable/topics/caching/). Maybe you need to set the `cache-dir` configuration setting somewhere (maybe through `pip.conf` or an environment variable, see [pip configuration doc](https://pip.pypa.io/en/stable/topics/configuration/)). – sinoroc Jun 06 '23 at 19:25
  • Can't one set the cache directory for individual downloads? – mYnDstrEAm Jun 06 '23 at 19:38
  • 1
    I do not know, maybe, it depends... If you use an environment variable combined with `--no-deps`, it might do what you need, something like: `PIP_CACHE_DIR=/some/directory python -m pip install --no-deps torch` (completely untested by me, I recommend you check the docs and experiment). -- But I agree that it should be possible to select options for single dependencies: https://discuss.python.org/t/proposal-overrides-for-installers/23666 – sinoroc Jun 06 '23 at 19:44

1 Answers1

-2

According to this answer, you need to use --target (-t) before the module name. So your new command becomes

"/media/.../python3" -m pip install -t "/directory/" torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
amycodes
  • 902
  • 14
  • I don't see where that answers says it needs to before the module name. It did not work and still downloads to the root partition of Debian. – mYnDstrEAm Jun 05 '23 at 22:52
  • It was the example they gave, and was a logical step, hence the advice. – amycodes Jun 06 '23 at 12:22