Skip to content

πŸ›[BUG]: No module named 'torch' when installing from SourceΒ #263

@ariellubonja

Description

@ariellubonja

Version

2a355de

On which installation method(s) does this occur?

Source

Describe the issue

Installing from source fails because of torch missing. This is caused by importing torch inside setup.py. Is there a way to fix this?

Minimum reproducible example

git clone [email protected]:NVIDIA/physicsnemo-sym.git && cd physicsnemo-sym

pip install --upgrade pip
pip install .

Relevant log output

ariel@ariel-Alienware-m16-R2:~/prog/ariel$ git clone https://github.com/NVIDIA/physicsnemo-sym.git
Cloning into 'physicsnemo-sym'...
remote: Enumerating objects: 4508, done.
remote: Counting objects: 100% (710/710), done.
remote: Compressing objects: 100% (408/408), done.
remote: Total 4508 (delta 416), reused 323 (delta 298), pack-reused 3798 (from 2)
Receiving objects: 100% (4508/4508), 204.95 MiB | 40.20 MiB/s, done.
Resolving deltas: 100% (2015/2015), done.
ariel@ariel-Alienware-m16-R2:~/prog/ariel$ cd physicsnemo-sym/
ariel@ariel-Alienware-m16-R2:~/prog/ariel/physicsnemo-sym$ pip install --upgrade pip
pip install .^C
ariel@ariel-Alienware-m16-R2:~/prog/ariel/physicsnemo-sym$ python3 -m venv .venv
ariel@ariel-Alienware-m16-R2:~/prog/ariel/physicsnemo-sym$ source .venv/bin/activate
(.venv) ariel@ariel-Alienware-m16-R2:~/prog/ariel/physicsnemo-sym$ pip install --upgrade pip
pip install .
Requirement already satisfied: pip in ./.venv/lib/python3.12/site-packages (24.0)
Collecting pip
  Using cached pip-25.2-py3-none-any.whl.metadata (4.7 kB)
Using cached pip-25.2-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 24.0
    Uninstalling pip-24.0:
      Successfully uninstalled pip-24.0
Successfully installed pip-25.2
Processing /home/ariel/prog/ariel/physicsnemo-sym
  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
  ╰─> [18 lines of output]
      Traceback (most recent call last):
        File "/home/ariel/prog/ariel/physicsnemo-sym/.venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/home/ariel/prog/ariel/physicsnemo-sym/.venv/lib/python3.12/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/ariel/prog/ariel/physicsnemo-sym/.venv/lib/python3.12/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-_4ntzb20/overlay/lib/python3.12/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-_4ntzb20/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 301, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-_4ntzb20/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())
        File "<string>", line 20, 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 wheel 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.

Environment details

Bare-metal

Other/Misc.

The workaround is to pip install torch then use pip install --no-build-isolation ., but was wondering if there's a cleaner way

Metadata

Metadata

Assignees

No one assigned

    Labels

    ? - Needs TriageNeed team to review and classifybugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions