Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'torch' #703

Open
Xephier102 opened this issue Jan 27, 2025 · 5 comments
Open

ModuleNotFoundError: No module named 'torch' #703

Xephier102 opened this issue Jan 27, 2025 · 5 comments

Comments

@Xephier102
Copy link

Xephier102 commented Jan 27, 2025

I've installed and reinstalled and recreated venvs and installed different versions, even installed a lower version of python(3.10.1), but, no matter what, when attempting to install this thing, I get the following error.

Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting autoawq
  Downloading autoawq-0.2.8.tar.gz (71 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "/home/xephier/DavesAI/pythonbullshit/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/home/xephier/DavesAI/pythonbullshit/lib/python3.10/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/xephier/DavesAI/pythonbullshit/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-x5r5s4dw/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-x5r5s4dw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-x5r5s4dw/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-x5r5s4dw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
          exec(code, locals())
        File "<string>", line 2, in <module>
      ModuleNotFoundError: No module named 'torch'
      [end of output]

I looked through all the issue's here and the only note I found on torch was the one regarding it's apparent dependency on torch 2.3.0. But, that didn't work, I even tried a much earlier version of torch (1.12.1), and 2.4.1, and initially started on the newest version (2.5.1).

Anyways, this thing don't seem to be able to find my torch install for whatever reason.

Edit: I think this issue might be more of a Python 3.13.1 thing.. Garuda(Linux) ninja'ed it in with my last chunk of updates, and it's screwing up everything on my PC.. Even after removing it as the global python. I'm getting 'module not found' errors while trying to run pip in a venv(different venv than the above), and apparently the PIL module isn't found either.. even after installing that multiple times.

Yea, nvm, this one's probably on me. Turns out my entire system got borked cuz some dkms directories didn't properly get updated/replaced during an Nvidia driver update (best I can tell, still gettin to the bottom of it). Will update if I have any more issues installing this after fixing the problem.

Edit: OK, got it solved. Not sure exactly what happened, but this command solved the issue.
pip install --upgrade pip setuptools wheel

@vnt-83
Copy link

vnt-83 commented Feb 7, 2025

pip install --upgrade pip setuptools wheel

Thanks! I had the same problem. And it helped me!

@jiqing-feng
Copy link
Contributor

Same error.

@VladKorolSU
Copy link

I experience the same issue. Tried on multiple machines, but installing autoawq works in Docker Nvidia container, specifically nvidia/cuda:12.6.1-cudnn-devel-ubuntu22.04. I also tried the fix suggested by @Xephier102 but that didn't work for me either. I am running:

pip install autoawq

And getting the following output:

Collecting autoawq (from -r requirements.txt (line 16))
  Downloading autoawq-0.2.8.tar.gz (71 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
          exec(compile('''
          ~~~~^^^^^^^^^^^^
          # This is <pip-setuptools-caller> -- a caller that pip uses to run setup.py
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ...<31 lines>...
          exec(compile(setup_py_code, filename, "exec"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          ''' % ('/tmp/pip-install-ceenwvqa/autoawq_6f91b9bdc97a4610aaaf9be285fa07e1/setup.py',), "<pip-setuptools-caller>", "exec"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-ceenwvqa/autoawq_6f91b9bdc97a4610aaaf9be285fa07e1/setup.py", line 2, in <module>
          import torch
      ModuleNotFoundError: No module named 'torch'

@casper-hansen
Copy link
Owner

Sorry if this is causing issues for everyone! You need to have torch pre-installed at the moment - this is a silly requirement as seen below. I think this is easily fixable in a PR as this is mostly for legacy purposes.

Image

@jiqing-feng
Copy link
Contributor

Do you mind check if this PR 715 helps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants