NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.42k stars 157 forks source link

Install fail in windows NameError: name 'nvdiffrast' is not defined #170

Closed suito-venus closed 7 months ago

suito-venus commented 8 months ago

Hi,

I fail install nvdiffrast module below error. Windows 10 cmd. python 3.11.10

python.exe -m pip install . 
Processing c:\workspaces_c\nvdiffrast
  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 "C:\workspaces_c\nvdiffrast\setup.py", line 18, in <module>
          version=nvdiffrast.__version__,
      NameError: name 'nvdiffrast' is not defined
      [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.

I thought in setup.py , using "import nvdiffrast" and "version=nvdiffrast.version," is self reference.

Thanks.

jannehellsten commented 8 months ago

Hi, the import nvdiffrast should be importing a module from a subdir called nvdiffrast, so the line is not intended to be self-referential.

What is the value of your PYTHONPATH environment variable when you invoke the above install? Ensure that it's unset. Only set it if you're using nvdiffrast without the pip install step.

suito-venus commented 8 months ago

Thanks for attention. In Python Packaging User Guide Single-sourcing the package version Says at 6. Set the value to version in sample/init.py and import sample in setup.py.

Warning

Although this technique is common, beware that it will fail if sample/init.py imports packages from install_requires dependencies, which will very likely not be installed yet when setup.py is run.

That's just same my case. Could you please consider it?

jannehellsten commented 8 months ago

@suito-venus odd, it doesn't seem to repro for us. I'm on Python 3.9 though.

Does pip install work if you edit setup.py and remove "import nvdiffrast" and modify this line:

    version=nvdiffrast.__version__,

->

    version= '1.2.3' # DEBUG DEBUG

packages from install_requires dependencies

nvdiffrast specifies only numpy as an install_requires dependency. Do you have that package installed?

suito-venus commented 8 months ago

@jannehellsten

Thanks for testing! I try to that( direct version writing like DEBUG ) then I can install nvdiffrast using pip.

nvdiffrast specifies only numpy as an install_requires dependency. Do you have that package installed?

Yes.

>python -m pip list 
Package                     Version
--------------------------- ------------------------
~~~~
numpy                       1.26.3
nvdiffrast                  0.3.1
~~~
jannehellsten commented 8 months ago

I guess it might work if you had installed pytorch before trying to install nvdiffrast. Torch is not listed as a peer dependency, but it must be installed before nvdiffrast. Numpy should come as part of installing torch then.

suito-venus commented 8 months ago

I re-test on clean python envrionment made by venv python 3.11. Result: No reproduction.

(venv) C:\workspaces_c\nvidffrast_repro_python311>python -m pip list
Package    Version
---------- -------
pip        24.0   
setuptools 65.5.0 

(venv) C:\workspaces_c\nvidffrast_repro_python311>python -m pip install git+https://github.com/NVlabs/nvdiffrast.git  
Collecting git+https://github.com/NVlabs/nvdiffrast.git
  Cloning https://github.com/NVlabs/nvdiffrast.git to c:\users\jun\appdata\local\temp\pip-req-build-yjz7hl_e
  Running command git clone --filter=blob:none --quiet https://github.com/NVlabs/nvdiffrast.git 'C:\Users\xxxx\AppData\Local\Temp\pip-req-build-yjz7hl_e'
  Resolved https://github.com/NVlabs/nvdiffrast.git to commit c5caf7bdb8a2448acc491a9faa47753972edd380
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting numpy (from nvdiffrast==0.3.1)
  Using cached numpy-1.26.4-cp311-cp311-win_amd64.whl.metadata (61 kB)
Using cached numpy-1.26.4-cp311-cp311-win_amd64.whl (15.8 MB)
Building wheels for collected packages: nvdiffrast
  Building wheel for nvdiffrast (pyproject.toml) ... done
  Created wheel for nvdiffrast: filename=nvdiffrast-0.3.1-py3-none-any.whl size=141468 sha256=91a39cf68e360dcbdafb0fc1a5c69cc4ec1e9687a15cf98fced819e391ee4985
  Stored in directory: C:\Users\jun\AppData\Local\Temp\pip-ephem-wheel-cache-_cokz8vl\wheels\1f\02\42\f8a0a54a25f789f27dd0a5509a22236057abd5d75f3f69969f
Successfully built nvdiffrast
Installing collected packages: numpy, nvdiffrast
Successfully installed numpy-1.26.4 nvdiffrast-0.3.1

(venv) C:\workspaces_c\nvidffrast_repro_python311>python -m pip list 
Package    Version
---------- -------
numpy      1.26.4
nvdiffrast 0.3.1
pip        24.0
setuptools 65.5.0

(venv) C:\workspaces_c\nvidffrast_repro_python311>

Same re-test in clean Python 3.10 environment. Result: No reproduction.

python -m pip install -e nvdiffrast
Obtaining file:///C:/workspaces_c/nvdiffrast_repro/nvdiffrast
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Installing backend dependencies ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting numpy (from nvdiffrast==0.3.1)
  Downloading numpy-1.26.4-cp310-cp310-win_amd64.whl.metadata (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 3.4 MB/s eta 0:00:00
Downloading numpy-1.26.4-cp310-cp310-win_amd64.whl (15.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.8/15.8 MB 73.1 MB/s eta 0:00:00
Building wheels for collected packages: nvdiffrast
  Building editable for nvdiffrast (pyproject.toml) ... done
  Created wheel for nvdiffrast: filename=nvdiffrast-0.3.1-0.editable-py3-none-any.whl size=5831 sha256=94215219fdcb386940b7b5b9f577233e22566fac8f80a94970117499324d3043
  Stored in directory: C:\Users\xxx\AppData\Local\Temp\pip-ephem-wheel-cache-xzd7ckz2\wheels\0c\f6\84\4e7a5bb72411a59c545833d2fe32bbf8490b0bcd4d785e82b4
Successfully built nvdiffrast
Installing collected packages: numpy, nvdiffrast
Successfully installed numpy-1.26.4 nvdiffrast-0.3.1

(venv) C:\workspaces_c\nvdiffrast_repro>python -m pip list
Package    Version Editable project location
---------- ------- -------------------------------------------
numpy      1.26.4
nvdiffrast 0.3.1   C:\workspaces_c\nvdiffrast_repro\nvdiffrast
pip        24.0
setuptools 65.5.0

(venv) C:\workspaces_c\nvdiffrast_repro>

I thouth that cause my python envrionment issue. My error cause environment is ComfyUI Python_embeded env. So many install is running on that environment ( and sometime make clash)

We apologize for my environment only issue.