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

No module named 'torch', why? #1892

Open
AITestPlatform2024 opened this issue Oct 13, 2024 · 7 comments
Open

No module named 'torch', why? #1892

AITestPlatform2024 opened this issue Oct 13, 2024 · 7 comments

Comments

@AITestPlatform2024
Copy link

Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Obtaining file:///E:/python310/GeneFacePlusPlus-main/GeneFacePlusPlus-main/pytorch3d-0.7.8/pytorch3d-0.7.8
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... 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 "E:\python310\GeneFacePlusPlus-main\GeneFacePlusPlus-main\myenv\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in
main()
File "E:\python310\GeneFacePlusPlus-main\GeneFacePlusPlus-main\myenv\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "E:\python310\GeneFacePlusPlus-main\GeneFacePlusPlus-main\myenv\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 132, in get_requires_for_build_editable
return hook(config_settings)
File "C:\Users\DELL\AppData\Local\Temp\pip-build-env-0bnzwr2a\overlay\Lib\site-packages\setuptools\build_meta.py", line 464, in get_requires_for_build_editable
return self.get_requires_for_build_wheel(config_settings)
File "C:\Users\DELL\AppData\Local\Temp\pip-build-env-0bnzwr2a\overlay\Lib\site-packages\setuptools\build_meta.py", line 332, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
File "C:\Users\DELL\AppData\Local\Temp\pip-build-env-0bnzwr2a\overlay\Lib\site-packages\setuptools\build_meta.py", line 302, in _get_build_requires
self.run_setup()
File "C:\Users\DELL\AppData\Local\Temp\pip-build-env-0bnzwr2a\overlay\Lib\site-packages\setuptools\build_meta.py", line 503, in run_setup
super().run_setup(setup_script=setup_script)
File "C:\Users\DELL\AppData\Local\Temp\pip-build-env-0bnzwr2a\overlay\Lib\site-packages\setuptools\build_meta.py", line 318, in run_setup
exec(code, locals())
File "", line 15, 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 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.

but I do have torch installed
(myenv) PS E:\python310\GeneFacePlusPlus-main\GeneFacePlusPlus-main\pytorch3d-0.7.8\pytorch3d-0.7.8> pip list | findstr /sina:c 'torch'
14:torch 2.4.1+cu124
15:torchaudio 2.4.1+cu124
16:torchvision 0.19.1+cu124

@bottler
Copy link
Contributor

bottler commented Oct 14, 2024

There's not enough information here to help you. What command are you running?

@AITestPlatform2024
Copy link
Author

error

There's not enough information here to help you. What command are you running?

@bottler
Copy link
Contributor

bottler commented Oct 14, 2024

I'm not sure why, but I think you need to clone the repo and then install from the local copy. pip is trying to build the library in an isolated environment, which won't work. There are other issues where people list what they did to install on Windows.

@HengYuD
Copy link

HengYuD commented Oct 18, 2024

try:
pip install --upgrade setuptools wheel

@harryseely
Copy link

harryseely commented Oct 29, 2024

Thanks @HengYuD !!!

Your suggestion worked.

try: pip install --upgrade setuptools wheel

I successfully installed on Windows 11 using Micromamba (highly recommend). I followed these setup steps specifically:

Install micromamba

Micromamba is a lightweight python package manager.
Install it for windows here

Set up Environment

  1. Open a terminal and check that micromamba is installed by running
micromamba
  1. Ensure micromamba is up-to-date by running
micromamba self-update
  1. Create a new environment
micromamba create -n rq3 python=3.9
micromamba activate rq3
  1. Install pytorch3d dependencies
micromamba install pytorch=1.13.0 torchvision pytorch-cuda=11.6 -c pytorch -c nvidia
micromamba install -c iopath iopath
  1. Install pytorch 3d from source
pip install --upgrade setuptools wheel
pip install "git+https://github.com/facebookresearch/pytorch3d.git@stable"
  1. Downgrade numpy (since using older version of torch)
micromamba install numpy<2

@ZamboniMarco99
Copy link

I'm not sure why, but I think you need to clone the repo and then install from the local copy. pip is trying to build the library in an isolated environment, which won't work. There are other issues where people list what they did to install on Windows.

Any plan on supporting the installation in isolated environments?
PEP 517 is almost 10 years and, for example, new buiild systems (like uv) by default follow those suggested guidelines. I'm sure that with time people will have more and more problems installing pytorch3d.

Migrating from setup.py to pyproject.toml(PEP 621) would be nice, but even in setup.py is there any reason why pytorch is not listed as an explicit dependency?

@harryseely
Copy link

I'm not sure why, but I think you need to clone the repo and then install from the local copy. pip is trying to build the library in an isolated environment, which won't work. There are other issues where people list what they did to install on Windows.

Any plan on supporting the installation in isolated environments? PEP 517 is almost 10 years and, for example, new buiild systems (like uv) by default follow those suggested guidelines. I'm sure that with time people will have more and more problems installing pytorch3d.

Migrating from setup.py to pyproject.toml(PEP 621) would be nice, but even in setup.py is there any reason why pytorch is not listed as an explicit dependency?

Yes please!

I use this library heavily for research but the difficulties regarding installation are a big barrier for the reproducibility of results...

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