pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

No module named 'torch', why?

Open AITestPlatform2024 opened this issue 1 year ago • 4 comments

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

AITestPlatform2024 avatar Oct 13 '24 16:10 AITestPlatform2024

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

bottler avatar Oct 14 '24 01:10 bottler

error

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

AITestPlatform2024 avatar Oct 14 '24 02:10 AITestPlatform2024

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.

bottler avatar Oct 14 '24 15:10 bottler

try: pip install --upgrade setuptools wheel

HengYuD avatar Oct 18 '24 06:10 HengYuD

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

harryseely avatar Oct 29 '24 17:10 harryseely

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?

ZamboniMarco99 avatar Oct 30 '24 11:10 ZamboniMarco99

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...

harryseely avatar Oct 30 '24 15:10 harryseely

try: pip install --upgrade setuptools wheel

This worked!.

I used the local install method by cloning the repo and then running pip install -e ., I was still getting errors for "torch not installed" even though I made sure I had it installed, until I upgraded setuptools as you suggested. This needs to be added in the README.md

fegarza7 avatar Jan 27 '25 14:01 fegarza7

After trying to re-install again, I just gave up and decided I need to use something else. I agree with @ZamboniMarco99, please either switch to pyproject.toml or fix setup.py.

harryseely avatar Jan 27 '25 15:01 harryseely

尝试:pip install --upgrade setuptools wheel

Tanks, its worked,

myd510 avatar Mar 10 '25 03:03 myd510

add --no-build-isolation

imxtx avatar May 24 '25 12:05 imxtx