Skip to content

Pip install doesn't recognize torch #1814

Open
@gboeer

Description

In my current setup, when installing yolox, the installation process exits with an error:

pip install -v -e .
AssertionError: torch is required for pre-compiling ops, please install it first.

However, torch is installed in my environment, as returned by pip list:

torch 2.0.1+cu117
torchvision 0.15.2+cu117

I am working with the most recent version:
d872c71

My python version is:

python --version
Python 3.10.15

The full error message is:

Using pip 24.2 from /home/appuser/.local/venv/lib/python3.10/site-packages/pip (python 3.10)
Obtaining file:///develop/YOLOX
  Running command pip subprocess to install build dependencies
  Using pip 24.2 from /home/appuser/.local/venv/lib/python3.10/site-packages/pip (python 3.10)
  Collecting setuptools>=40.8.0
    Obtaining dependency information for setuptools>=40.8.0 from https://files.pythonhosted.org/packages/55/21/47d163f615df1d30c094f6c8bbb353619274edccf0327b185cc2493c2c33/setuptools-75.6.0-py3-none-any.whl.metadata
    Using cached setuptools-75.6.0-py3-none-any.whl.metadata (6.7 kB)
  Using cached setuptools-75.6.0-py3-none-any.whl (1.2 MB)
  Installing collected packages: setuptools
  Successfully installed setuptools-75.6.0
  Installing build dependencies ... done
  Running command Checking if build backend supports build_editable
  Checking if build backend supports build_editable ... done
  Running command Getting requirements to build editable
  [WARNING] Unable to import torch, pre-compiling ops will be disabled.
  Traceback (most recent call last):
    File "/home/appuser/.local/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/home/appuser/.local/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/appuser/.local/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 132, in get_requires_for_build_editable
      return hook(config_settings)
    File "/tmp/pip-build-env-_ks8t9e7/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 483, in get_requires_for_build_editable
      return self.get_requires_for_build_wheel(config_settings)
    File "/tmp/pip-build-env-_ks8t9e7/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=[])
    File "/tmp/pip-build-env-_ks8t9e7/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-_ks8t9e7/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 522, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/tmp/pip-build-env-_ks8t9e7/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
      exec(code, locals())
    File "<string>", line 77, in <module>
    File "<string>", line 50, in get_ext_modules
  AssertionError: torch is required for pre-compiling ops, please install it first.
  error: subprocess-exited-with-error
  
  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/appuser/.local/venv/bin/python3 /home/appuser/.local/venv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py get_requires_for_build_editable /tmp/tmpn2i8m2cc
  cwd: /develop/YOLOX
  Getting requirements to build editable ... error

[notice] A new release of pip is available: 24.2 -> 24.3.1
[notice] To update, run: pip install --upgrade pip
error: subprocess-exited-with-error

× Getting requirements to build editable did not run successfully.
│ exit code: 1
╰─> See above for output.

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions