Error downloading pytorch: "AttributeError: module ‘light_the_torch’ has no attribute ‘find_links’"

Hello,
I want to download PyTorch to use TorchIO for the data augmentation process.
I installed TorchIO and PyTorch Utils, but when I tried to install PyTorch using PyTorch Utils it gave me an attribution error.
I tried the installation on 3D slicer version 4.13.0 and 5.1.0 using my window10 computer, but nothing worked.
I tested installation on a different computer, which worked fine and confused me even more.
I got the following message.
Could you please give me some advice?
Thank you very much.

Importing torch…
Querying light-the-torch for torch wheel…
Requirement already satisfied: light-the-torch in c:\users\njy95\appdata\local\na-mic\slicer 5.1.0-2022-06-14\lib\python\lib\site-packages (0.4.0)
Requirement already satisfied: pip!=22.0,!=22.0.1,!=22.0.2,<22.2,>=22.0 in c:\users\njy95\appdata\local\na-mic\slicer 5.1.0-2022-06-14\lib\python\lib\site-packages (from light-the-torch) (22.0.3)
WARNING: You are using pip version 22.0.3; however, version 22.1.2 is available.
You should consider upgrading via the ‘C:\Users\njy95\AppData\Local\NA-MIC\Slicer 5.1.0-2022-06-14\bin\python-real.exe -m pip install --upgrade pip’ command.
Traceback (most recent call last):
File “C:/Users/njy95/AppData/Local/NA-MIC/Slicer 5.1.0-2022-06-14/NA-MIC/Extensions-31027/PyTorch/lib/Slicer-5.1/qt-scripted-modules/PyTorchUtils.py”, line 40, in onInstallTorch
torch = PyTorchUtilsLogic().torch
File “C:/Users/njy95/AppData/Local/NA-MIC/Slicer 5.1.0-2022-06-14/NA-MIC/Extensions-31027/PyTorch/lib/Slicer-5.1/qt-scripted-modules/PyTorchUtils.py”, line 55, in torch
self._torch = self.importTorch()
File “C:/Users/njy95/AppData/Local/NA-MIC/Slicer 5.1.0-2022-06-14/NA-MIC/Extensions-31027/PyTorch/lib/Slicer-5.1/qt-scripted-modules/PyTorchUtils.py”, line 80, in importTorch
torch = self.installTorch()
File “C:/Users/njy95/AppData/Local/NA-MIC/Slicer 5.1.0-2022-06-14/NA-MIC/Extensions-31027/PyTorch/lib/Slicer-5.1/qt-scripted-modules/PyTorchUtils.py”, line 99, in installTorch
slicer.util.pip_install(self.wheelURL)
File “C:/Users/njy95/AppData/Local/NA-MIC/Slicer 5.1.0-2022-06-14/NA-MIC/Extensions-31027/PyTorch/lib/Slicer-5.1/qt-scripted-modules/PyTorchUtils.py”, line 63, in wheelURL
self._wheel = self.getTorchUrl()
File “C:/Users/njy95/AppData/Local/NA-MIC/Slicer 5.1.0-2022-06-14/NA-MIC/Extensions-31027/PyTorch/lib/Slicer-5.1/qt-scripted-modules/PyTorchUtils.py”, line 114, in getTorchUrl
wheelUrl = ltt.find_links([‘torch’])[0]
AttributeError: module ‘light_the_torch’ has no attribute ‘find_links’

@Fernando recently pushed Add upper bound for light-the-torch requirement · fepegar/SlicerPyTorch@b1f33d6 · GitHub to address this issue by using a 2020 version of pip instead of the newer 2022 version of pip included by default in Slicer. You will be able to update the PyTorch Slicer extension tomorrow to get this latest versions or you can directly install PyTorch with the method in the linked commit.

4 Likes

Thank you so much for your help!
I was able to install pytorch with the link you provided!! :slight_smile: