teddykoker / torchsort

Fast, differentiable sorting and ranking in PyTorch
https://pypi.org/project/torchsort/
Apache License 2.0
765 stars 33 forks source link

Pip install throws error #65

Closed helpful-sam closed 8 months ago

helpful-sam commented 1 year ago

Environment:

Error:

Building wheels for collected packages: torchsort
  Building wheel for torchsort (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      running bdist_wheel
      C:\Users\Sam\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py:387: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
        warnings.warn(msg.format('we could not find ninja.'))
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.9
      creating build\lib.win-amd64-3.9\torchsort
      copying torchsort\ops.py -> build\lib.win-amd64-3.9\torchsort
      copying torchsort\__init__.py -> build\lib.win-amd64-3.9\torchsort
      running egg_info
      writing torchsort.egg-info\PKG-INFO
      writing dependency_links to torchsort.egg-info\dependency_links.txt
      writing requirements to torchsort.egg-info\requires.txt
      writing top-level names to torchsort.egg-info\top_level.txt
      reading manifest file 'torchsort.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'torchsort.egg-info\SOURCES.txt'
      copying torchsort\isotonic_cpu.cpp -> build\lib.win-amd64-3.9\torchsort
      copying torchsort\isotonic_cuda.cu -> build\lib.win-amd64-3.9\torchsort
      running build_ext
      C:\Users\Sam\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py:322: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
        warnings.warn(f'Error checking compiler version for {compiler}: {error}')
      building 'torchsort.isotonic_cpu' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for torchsort
  Running setup.py clean for torchsort
Failed to build torchsort
Installing collected packages: torchsort
  Running setup.py install for torchsort ... error
  error: subprocess-exited-with-error

  × Running setup.py install for torchsort did not run successfully.
  │ exit code: 1
  ╰─> [25 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.9
      creating build\lib.win-amd64-3.9\torchsort
      copying torchsort\ops.py -> build\lib.win-amd64-3.9\torchsort
      copying torchsort\__init__.py -> build\lib.win-amd64-3.9\torchsort
      running egg_info
      writing torchsort.egg-info\PKG-INFO
      writing dependency_links to torchsort.egg-info\dependency_links.txt
      writing requirements to torchsort.egg-info\requires.txt
      writing top-level names to torchsort.egg-info\top_level.txt
      C:\Users\Sam\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py:387: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
        warnings.warn(msg.format('we could not find ninja.'))
      reading manifest file 'torchsort.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      writing manifest file 'torchsort.egg-info\SOURCES.txt'
      copying torchsort\isotonic_cpu.cpp -> build\lib.win-amd64-3.9\torchsort
      copying torchsort\isotonic_cuda.cu -> build\lib.win-amd64-3.9\torchsort
      running build_ext
      C:\Users\Sam\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\cpp_extension.py:322: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
        warnings.warn(f'Error checking compiler version for {compiler}: {error}')
      building 'torchsort.isotonic_cpu' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> torchsort

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
teddykoker commented 1 year ago

Hi @helpful-sam, the error message seems to indicate "Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools". Are you sure it is installed and accessible via the command line?

helpful-sam commented 1 year ago

Ah, I had the runtime library installed, thank you for the clarification!

helpful-sam commented 1 year ago

Sorry about this, but I'm a novice in this stuff, but I installed the build tools via the link provided in the error output, but I am unsure of how to approach making sure that the MS build tools are accessible via CMD. I did try "cl" on the cmd, but it did not recognize the command, but I do know I installed the build tools. Did I have to install the extra packages during the installation of Visual Studios?

teddykoker commented 1 year ago

I am not very familiar with development on Windows, but reading Use the Microsoft C++ toolset from the command line it seems like you should be able to use a command prompt shortcut, or one of the developer command files, which should add all of the required tools to your path.

teddykoker commented 8 months ago

Closing due to inactivity.