setuptools: [BUG] Cannot import torch when installation torch extension packages

setuptools version

setuptools==69.1.0

Python version

Python 3.12.2

OS

Windows

Additional environment information

This is only happening in “Python 3.12.2 + Windows + setuptools==69.1.0”

Description

python3 -m pip install --verbose --upgrade git+https://github.com/microsoft/tutel@main

My testing in different environment:

Python 3.12.0 + Windows + setuptools==69.1.0: Installation Passed ✓

Python 3.12.2 + Windows + setuptools==69.1.0: Installation Failed: × ModuleNotFoundError: No module named ‘torch’ (I ensure I have installed torch package for Python3.12.2)

Python 3.12.0 + Ubuntu + setuptools==69.1.0: Installation Passed ✓

Python 3.8.6 + Ubuntu + setuptools==69.1.0: Installation Passed ✓

Under Linux, I don’t find any issues using any versions of Pytorch.

Expected behavior

Python 3.12.2 + Windows + setuptools==69.1.0 should work normally like other platforms and python versions.

How to Reproduce

Under Windows + Python3.12.2 + Torch:<any>:

python3 -m pip install --verbose --upgrade git+https://github.com/microsoft/tutel@main

Above command should detect and import package correctly.

Output

This is the error output using Python3.12.2:

  Running command Getting requirements to build wheel
  Traceback (most recent call last):
    File "C:\Users\develop\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
    File "C:\Users\develop\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\develop\AppData\Local\Programs\Python\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\develop\AppData\Local\Temp\pip-build-env-ijd5_0va\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\develop\AppData\Local\Temp\pip-build-env-ijd5_0va\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
      self.run_setup()
    File "C:\Users\develop\AppData\Local\Temp\pip-build-env-ijd5_0va\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
      super().run_setup(setup_script=setup_script)
    File "C:\Users\develop\AppData\Local\Temp\pip-build-env-ijd5_0va\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 19, in <module>
  ModuleNotFoundError: No module named 'torch'
  error: subprocess-exited-with-error

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Other options also don’t work: $ pip install --verbose --upgrade --no-build-isolation git+https://github.com/microsoft/tutel@main

Please note that if you do that you need to install all build dependencies. I have previuosly mentioned:

Alternatively, if you want to disable “build isolation” you can run pip install with the --no-build-isolation and/or --no-use-pep517 flags (if you do that you need to ensure all the build dependencies are installed, including setuptools and wheel).

By the looks of the logs, it seems like wheel was not installed.