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' while installing torch-scatter using pip on MacOS #424

Open
atharvabagde opened this issue Mar 2, 2024 · 5 comments

Comments

@atharvabagde
Copy link

atharvabagde commented Mar 2, 2024

I am unable to install torch-scatter using the following command : pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cpu.html

Getting the following error:

(project_990) atharvbagde@Atharvs-Laptop ~ % pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cpu.html
Looking in links: https://data.pyg.org/whl/torch-2.1.0+cpu.html
Collecting torch-scatter
Using cached torch_scatter-2.1.2.tar.gz (108 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 "/Users/atharvbagde/.pyenv/versions/3.10.4/envs/project_990/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/Users/atharvbagde/.pyenv/versions/3.10.4/envs/project_990/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 "/Users/atharvbagde/.pyenv/versions/3.10.4/envs/project_990/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/private/var/folders/rh/0y4zwnyd49l6pmndmmg3lh7h0000gn/T/pip-build-env-u4d8oq9d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/private/var/folders/rh/0y4zwnyd49l6pmndmmg3lh7h0000gn/T/pip-build-env-u4d8oq9d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "/private/var/folders/rh/0y4zwnyd49l6pmndmmg3lh7h0000gn/T/pip-build-env-u4d8oq9d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "/private/var/folders/rh/0y4zwnyd49l6pmndmmg3lh7h0000gn/T/pip-build-env-u4d8oq9d/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "", line 8, in
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.

Python Virtual env details
Python: 3.10.4
pip: 24.0
Torch: 2.1.0 (installed using pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0)
Torch-geometric: 2.5.0 (installed using pip install torch_geometric)

MacOS M2 chip

Let me know if any other details are required

@atharvabagde atharvabagde changed the title ModuleNotFoundError: No module named 'torch' while installing torch-scatter using pip ModuleNotFoundError: No module named 'torch' while installing torch-scatter using pip on MacOS Mar 2, 2024
@rusty1s
Copy link
Owner

rusty1s commented Mar 3, 2024

Can you try to install via

git clone https://github.com/rusty1s/pytorch_scatter.git
python setup.py install

@atharvabagde
Copy link
Author

Yes, this does work!
Are there any changes I need to make in order to install via pip? Because I am able to install simply via pip on Colab but it fails on my local Mac

@rusty1s
Copy link
Owner

rusty1s commented Mar 4, 2024

We would have to bring rusty1s/pytorch_cluster#208 also to torch-scatter.

@Niknymusing
Copy link

This didn't work on my m2 mac;

git clone https://github.com/rusty1s/pytorch_scatter.git

python setup.py install

...
torch_scatter.pycache._version_cpu.cpython-310: module references file
No eggs found in /var/folders/qd/7w_wvc4n7bzbkmq4z365ct0m0000gn/T/easy_install-jisophmk/torch_scatter-2.1.2/egg-dist-tmp-e5t_vr5h (setup script problem?)
error: The 'torch-scatter==2.1.2' distribution was not found and is required by the application

@ftherrien
Copy link

I am still experiencing this problem with python 3.10.12 in a fresh env:

ftherrien@PC:~$ python3 -m venv test_scatter
ftherrien@PC-T-023:~$ source test_scatter/bin/activate
(test_scatter) felixtherrien@PC-T-023:~$ pip install torch torch_scatter
Collecting torch
  Using cached torch-2.4.0-cp310-cp310-manylinux1_x86_64.whl (797.2 MB)
Collecting torch_scatter
  Using cached torch_scatter-2.1.2.tar.gz (108 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-1k0yl7an/torch-scatter_e0a829bbf9b74ac7aa18fde0308f48c6/setup.py", line 8, in <module>
          import torch
      ModuleNotFoundError: No module named 'torch'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

The following solves it:

pip install torch
pip install --no-use-pep517 torch_scatter

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

4 participants