I could not install torch
due to an OSError:
[Errno 2] No such file or directory
The error code I received after inputting pip install torch
was this:
ERROR: Could not install packages due to an OSError:
[Errno 2] No such file or directory: 'C:\\Users\\T0926727H\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\torch\\include\\ATen\\ops\\_fake_quantize_per_tensor_affine_cachemask_tensor_qparams_compositeexplicitautograd_dispatch.h'
Would appreciate the help!
I read through the answers given and tried out this pip install torch --user
instead of pip install torch
.
Despite this working for many others, it still did not work for me.
I think you're hitting the Windows 10 path character limit, which is 260 characters. Your path name is 275 characters. I would recommend either shortening that, or going into regedit to enable long path names. But just a warning, messing around with regedit can sometimes have machine-breaking level consequences. I avoid it whenever possible.
To enable long file paths in Windows, open Registry Editor, create a new DWORD named "LongPathsEnabled" in "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" and set the value to 1. Pro and Enterprise users can enable "Enable Win32 Long Paths" in the Local Group Policy Editor.
From https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/.
I think you might have installed Python through the Microsoft store. If you uninstall Python, then install Python from the Python website, your path name will be much shorter, and you'll probably be able to install pytorch
without editing the registry.