Closed mengyuest closed 5 years ago
Yes I am aware that this can happen if you try to run the examples from the root folder of the repo. The local directory is named neural_renderer because this is the standard practice when distributing python packages (you need to supply a setup.py and place your package named foo under the foo/ directory). One problem here is that neural_renderer.cuda.load_textures is an external module written in C++ and CUDA and not a Python module, and is compiled when you run setup.py So when you try to import anything that starts with neural renderer and you are in the root folder it may shadow a globally installed package.
Check for example this package:
I had the same problem, I'm using pycharm. The problem is beacause the import package can't be in the same path with the demo.py. My solution is copy the /neural_renderer to another path, then add it as an external lib.
Hi, I tried the code and could not execute
python3 ./examples/example1.py
successfully. It raised the errorIt seems like to be a "name shadowing" problem as the local package name conflicts with the installed packages. After altering the inner (second) "neural_renderer" filename to others, it worked as expected. Could it be better to rename the local dirname or just mention that in the README.md? I am not sure whether this is a common issue. I am using
python3
. Thanks.PS: Referenced from The name shadowing trap
A simple case for showing "name shadowing" is (assuming you have
numpy
)mkdir numpy
touch numpy/__init__.py
python3 -c "import numpy.random"
and you will get "No module named..." error