You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I tried the code and could not execute python3 ./examples/example1.py successfully. It raised the error
Traceback (most recent call last):
File "examples/example1.py", line 12, in <module>
import neural_renderer as nr
File "/foo/bar/neural_renderer/neural_renderer/__init__.py", line 3, in <module>
from .load_obj import load_obj
File "/foo/bar/neural_renderer/neural_renderer/load_obj.py", line 8, in <module>
import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: No module named 'neural_renderer.cuda.load_textures'
It 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.
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
The text was updated successfully, but these errors were encountered:
mengyuest
changed the title
The name shadowing for the package 'neural_renderer'
The name shadowing issue for the package 'neural_renderer'
Aug 30, 2018
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.
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..." errorThe text was updated successfully, but these errors were encountered: