No module named 'pyngp'
zxzxde opened this issue ยท 16 comments
Missing In run.py
I have the same problem.
Please check your CMake/build logs for whether Python was detected and pyngp
actually built.
If CMake can't detect your Python installation, it will only build the testbed
binary. Further, if pyngp
was built in different folder than instant-ngp/build
, run.py will be unable to detect it and you have to supply the correct path to the import statement.
to expand on this a little in case it helps you understand the root cause (tho the advice Tom94 gives is the right thing to actually take action on) - the python binding relies on there being a file with a filename something like pyngp.cp39-win_amd64.pyd
in your path (but see below). this (on windows) may also depend on some dlls such as cublas64_11.dll
and `cublasLt64_11.dll' (some of the numbers in those filenames will depend on your python and cuda versions, so they are just for illustration).
so - all these files (the pyd and the cublas dlls) must be in your path. but... how do they get there?
if everything has built as expected, all of those files should actually be found in your instant-ngp/build folder. (if they are not there, you have a build issue). then, what happens is that the scripts/run.py (by way of some code early in scripts/common.py) explicitly adds the build/ folder to your path, in order that python can find these files. voila!
the error you are seeing is basically that python cannot find these files in your path, and the code in common.py is failing to add a useful directory somehow. perhaps the files are not there, or not in the build/ folder, or perhaps you are running a different version of python than the one that was built against.
I have seen a windows setup where running 'python' ran (say) 3.9, but cmake had built instant-ngp against (say) 3.7 or 3.8. it may be worth checking what version of python you are running run.py through, vs what verision is in the filename of the .pyd file.
Hi, the built python lib is in your build directory.
For me it is named as pyngp.cpython-37m-x86_64-linux-gnu.so
, which means it is compiled by python 3.7.
As mmalex said, just add following codes in run.py:
pyngp_path = '/path/to/your/build'
sys.path.append(pyngp_path)
import pyngp as ngp
Replace the pyngp_path
with your actually build path.
Please make sure that the python version used for running codes matches the version of .so file.
My file name is called pyngp.cp310-win_amd64 which made me believe it's for python 3.10. But when updating to python 3.10 all kinds of other modules break and I think it would be easier to build a 3.9 version of pyngp. But I have no clue how to do that.
@624memorials I had exactly the same issue. I resolved it by doing the following.
First, I followed MiZhenxing's advice by adding the following code to the 'run.py' file:
pyngp_path = '\build'
sys.path.append(pyngp_path)
import pyngp as ngp # this line should already be there near the top of the code
I then installed python version 3.10 into the virtual environment
conda install python=3.10
This will ask you for confirmation that it will automatically update or downgrade various packages. This should hopefully work for you. Happy coding!
I had this problem and realised it was because I installed Python after I had already run the make.
Now python is there, I will redo the make, and I suspect it will work.
i've been fighting with this problem all bloody day ;p .. i finally figure it out.. i just renamed pyngp.cp39-win_amd64.pyd (or whatever yours is called) to pyngp.pyd and it worked
I also had this issue, documenting what worked for me here in case it helps others.
I'm on Windows, and had run the cmake commands in a Developer powershell, but was running my python in an Anaconda shell inside an Anaconda environment. This meant that the python that cmake saw and the python that the scripts saw was different, and so it couldn't find pyngp.
To fix this, I first set up the Developer powershell to use conda. In the shell, I went to my conda install directory (C:\Users<usnerame>\anaconda3\condabin) and ran conda init
. Next, I launched a Developer powershell AS ADMINISTRATOR, and ran Set-ExecutionPolicy RemoteSigned
, which is required to let conda run its set up scripts when launching a new shell. Then, I launched a fresh shell, and was able to use conda activate ngp
to enter my conda environment (which I had named "ngp").
Next, I removed my old build folder. I had previously tried just running cmake again, but that didn't fix it. I needed to remove build, and re-run cmake from scratch within the conda environment. After doing this, all my pythons were in agreement, and I could import pyngp without issue.
To add to the post above โ I simply opened a new Developer powershell and rebuilt the library (cmake
), but with the correct conda env activated (and pyexr
already pip installed).
command to execute
py -3.9 scripts/run.py --scene data/nerf/fox/transforms.json
To add to the post above โ I simply opened a new Developer powershell and rebuilt the library (
cmake
), but with the correct conda env activated (andpyexr
already pip installed).
I followed this instruction, but I got this: "ImportError: DLL load failed while importing pyngp: the given module is not found."
Change the python version (here from 3. 7 in the download ) in the cmakelist file to the your environment python version (3.10 in my PC). then cmake and build again. Then it works
if (NGP_BUILD_WITH_PYTHON_BINDINGS)
find_package(Python 3.10 COMPONENTS Interpreter Development)
if (Python_FOUND)
add_subdirectory("dependencies/pybind11")
endif()
endif()
If someone else is wondering how to install Instant-NGP with a specific Python version (other than the currently activated version), it can be done by adding the following flags to the build command:
cmake . -B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DPython_EXECUTABLE:FILEPATH=/path_to_python/bin/python3 \
-DPython_LIBRARIES:FILEPATH=/path_to_python/lib/libpython3.10.so \
-DPython_INCLUDE_DIR:PATH=/path_to_python/include/python3.10
Personnally, I struggled with this error for a day and I could run scripts/run.py changing "/path/to/python" in build/CMakeCache.txt by my current path to python. I work with conda and it seems to work now.
I got the following error
(pinerf) user@5a94046bed44:/workspace/pose_estimation/ParallelInversion/scripts$ python run_debug.py --config config/debug/default.yaml
Traceback (most recent call last):
File "/workspace/pose_estimation/ParallelInversion/scripts/run_debug.py", line 28, in
import pyngp as ngp # noqa
ImportError: /home/user/.conda/envs/pinerf/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /workspace/pose_estimation/ParallelInversion/build/pyngp.cpython-39-x86_64-linux-gnu.so)
And solved it by this:
conda config --set ssl_verify no
conda install -c conda-forge gcc=12.1.0