devit icon indicating copy to clipboard operation
devit copied to clipboard

No module named 'torch' when pip install -e .

Open rabum opened this issue 4 months ago • 8 comments

When I tried to install the project with line pip install -e . there seems to be a problem: DEPRECATION: Legacy editable install of detectron2==0.6 from file:///home/yunzheng/devit (setup.py develop) is deprecated. pip 25.3 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457 Running setup.py develop for detectron2 error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [83 lines of output]
    /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/torch/utils/cpp_extension.py:25: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
      from pkg_resources import packaging  # type: ignore[attr-defined]
    running develop
    /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:90: DevelopDeprecationWarning: develop command is deprecated.
    !!

            ********************************************************************************
            Please avoid running ``setup.py`` and ``develop``.
            Instead, use standards-based tools like pip or uv.

            By 2025-Oct-31, you need to update your project and remove deprecated calls
            or your builds will no longer be supported.

            See https://github.com/pypa/setuptools/issues/917 for details.
            ********************************************************************************

    !!
      self.initialize_options()
    WARNING: Ignoring invalid distribution -etectron2 (/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages)
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Obtaining file:///home/yunzheng/devit
      Installing build dependencies: started
      Installing build dependencies: finished with status 'done'
      Checking if build backend supports build_editable: started
      Checking if build backend supports build_editable: finished with status 'done'
      Getting requirements to build editable: started
      Getting requirements to build editable: finished with status 'error'
      error: subprocess-exited-with-error

      × Getting requirements to build editable did not run successfully.
      │ exit code: 1
      ╰─> [19 lines of output]
          Traceback (most recent call last):
            File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
              main()
            File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
              json_out["return_val"] = hook(**hook_input["kwargs"])
            File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 157, in get_requires_for_build_editable
              return hook(config_settings)
            File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 473, in get_requires_for_build_editable
              return self.get_requires_for_build_wheel(config_settings)
            File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
              return self._get_build_requires(config_settings, requirements=[])
            File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
              self.run_setup()
            File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 512, in run_setup
              super().run_setup(setup_script=setup_script)
            File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 317, in run_setup
              exec(code, locals())
            File "<string>", line 10, in <module>
          ModuleNotFoundError: No module named 'torch'
          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with 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.
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 35, in <module>
      File "/home/yunzheng/devit/setup.py", line 194, in <module>
        setup(
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/__init__.py", line 115, in setup
        return distutils.core.setup(**attrs)
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 186, in setup
        return run_commands(dist)
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
        dist.run_commands()
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
        self.run_command(cmd)
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/dist.py", line 1102, in run_command
        super().run_command(command)
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
        cmd_obj.run()
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/command/develop.py", line 39, in run
        subprocess.check_call(cmd)
      File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/subprocess.py", line 373, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/home/yunzheng/anaconda3/envs/devit/bin/python3.9', '-m', 'pip', 'install', '-e', '.', '--use-pep517', '--no-deps']' returned non-zero exit status 1.
    [end of output]

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

Rolling back uninstall of detectron2 Moving to /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/detectron2-0.6.dist-info/ from /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/~etectron2-0.6.dist-info Moving to /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/detectron2/ from /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/~etectron2 Moving to /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/tools/ from /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/~ools error: subprocess-exited-with-error

× python setup.py develop did not run successfully. │ exit code: 1 ╰─> [83 lines of output] /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/torch/utils/cpp_extension.py:25: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. from pkg_resources import packaging # type: ignore[attr-defined] running develop /home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:90: DevelopDeprecationWarning: develop command is deprecated. !!

        ********************************************************************************
        Please avoid running ``setup.py`` and ``develop``.
        Instead, use standards-based tools like pip or uv.

        By 2025-Oct-31, you need to update your project and remove deprecated calls
        or your builds will no longer be supported.

        See https://github.com/pypa/setuptools/issues/917 for details.
        ********************************************************************************

!!
  self.initialize_options()
WARNING: Ignoring invalid distribution -etectron2 (/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Obtaining file:///home/yunzheng/devit
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Getting requirements to build editable: started
  Getting requirements to build editable: finished with status 'error'
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Traceback (most recent call last):
        File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
        File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 157, in get_requires_for_build_editable
          return hook(config_settings)
        File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 473, in get_requires_for_build_editable
          return self.get_requires_for_build_wheel(config_settings)
        File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 331, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
        File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 512, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-lex6_u5a/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
        File "<string>", line 10, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with 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.
Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "<pip-setuptools-caller>", line 35, in <module>
  File "/home/yunzheng/devit/setup.py", line 194, in <module>
    setup(
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/__init__.py", line 115, in setup
    return distutils.core.setup(**attrs)
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 186, in setup
    return run_commands(dist)
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
    dist.run_commands()
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands
    self.run_command(cmd)
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/dist.py", line 1102, in run_command
    super().run_command(command)
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command
    cmd_obj.run()
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/site-packages/setuptools/command/develop.py", line 39, in run
    subprocess.check_call(cmd)
  File "/home/yunzheng/anaconda3/envs/devit/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/yunzheng/anaconda3/envs/devit/bin/python3.9', '-m', 'pip', 'install', '-e', '.', '--use-pep517', '--no-deps']' returned non-zero exit status 1.
[end of output]

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

rabum avatar Aug 29 '25 02:08 rabum

Have you solved it? I've run into the same problem too.

zoupeipei666 avatar Oct 09 '25 08:10 zoupeipei666

Did anyone find the solution? I have the same issue.

Daniel-Zarsky avatar Oct 16 '25 08:10 Daniel-Zarsky

same problem

huytuong010101 avatar Nov 01 '25 02:11 huytuong010101

Same problem,

@huytuong010101 nào fix được chỉ anh với nha :)))

KudoKhang avatar Nov 02 '25 07:11 KudoKhang

@KudoKhang qua install repo ni anh giai: https://github.com/mlzxy/devit/issues/88

huytuong010101 avatar Nov 02 '25 14:11 huytuong010101

@KudoKhang qua install repo ni anh giai: #88

Anh chạy được rồi, không biết có sai sót gì không mà thời gian inference 1 phút lận. Em cũng đang làm ZaloAI challenge hở

KudoKhang avatar Nov 02 '25 14:11 KudoKhang

yup, lâu z hả z thôi e khỏi thử 😄

huytuong010101 avatar Nov 02 '25 14:11 huytuong010101

Downgrading setuptools could solve this problem. You can run pip install "setuptools<60" before running pip install -e .

zhuomo-1 avatar Nov 04 '25 08:11 zhuomo-1

use the "pip install -e . --no-build-isolation" have successful install at linux

hongtao11 avatar Dec 01 '25 08:12 hongtao11