ImportError: No module named nets
when I enter : python object_detection/builders/model_builder_test.py
it shows the wrong : ImportError: No module named nets
could you help me?
thank you very much
Look at Installation!!! When running locally, the tensorflow/models/ and slim directories should be appended to PYTHONPATH. This can be done by running the following from tensorflow/models/:
From tensorflow/models/
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
nets and deployment modules belong to slim
'pwd' is the path of models folder. Try to set "pwd:pwd/slim" with "/media/media_share/linkfile/models: /media/media_share/linkfile/models/slim".
2017-07-04 9:32 GMT+08:00 10183308 [email protected]:
thank you .
I have added the PYTHONPATH ,
but it does not work.
hc@hc-PC:/media/media_share/linkfile/models$ echo $PYTHONPATH /usr/local/lib/python2.7/dist-packages:/usr/lib/python2.7/ dist-packages:/home/hc/project/caffe2/caffe2/build/ caffe2:/home/hc/project/caffe2/caffe2/build/caffe2/ python:/home/hc/project/caffe_sorce/caffe/python:/usr/local: /home/hc/project/caffe_sorce/caffe/python:/usr/local:/home/ hc/project/caffe2/caffe2/build::/home/hc:/home/hc/slim: /home/hc:/home/hc/slim:pwd:pwd/slim
hc@hc-PC:/media/media_share/linkfile/models$ python object_detection/builders/model_builder_test.py Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", line 21, in from object_detection.builders import model_builder File "/media/media_share/linkfile/models/object_detection/builders/model_builder.py", line 30, in from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "/media/media_share/linkfile/models/object_detection/ models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 29, in from nets import inception_resnet_v2 ImportError: No module named nets
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tensorflow/models/issues/1842#issuecomment-312759640, or mute the thread https://github.com/notifications/unsubscribe-auth/AQrfnvlM0XfHYhlj-2gMb1e3up1qAjxoks5sKZY2gaJpZM4OL73k .
Ah, it is the problem of "path"! I have trying for several days. When I added in the program code: "import sys print(sys.path) sys.path.append("/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim") print(sys.path)" It works! For the nets.py in directory"/usr/local/lib/python2.7/dist-packages/tensorflow/contrib/slim"
Congratulate to work it well.You can find the slim folder in models folder, and nets folder in the slim folder.I work it on windows, like this:
.
so I just add this slim to the path.on the linux, you can try it similarly.
I think it's a trick.... in the document, it said
export PYTHONPATH=$PYTHONPATH:'pwd':'pwd'/slim
pwd is your local path, however, you should keep mark like this : 'local path':'localpath'/slim it works on my computer. 哇,喷火龙唉!
Thanks a lot!
Thanks a lot. It worked for me
Thank you for all! I have solved this problem by run setup.py. Thank you!
Thanks!!! running setup.py build and setup.py install worked
sudo gedit ~/.bashrc #open bashrc file #then add this new line to the end of your bashrc file export PYTHONPATH=$PYTHONPATH=/home/hri/tensorflow/models/research:/home/hri/tensorflow/models/research/slim #then restart then bashrc to make it work source ~/.bashrc #you can change the path to your own!
I encountered the same problem on windows. What I did was, I just copied the entire nets folder from slim directory to C:\Python\Python35\Lib\site-packages\object_detection-0.1-py3.5.egg (where I installed object_detection API). Then the error is completely gone.
I have the same problem and I go to the tensorflow's github for information
You can never figure it out that I solve this by simply copy the code below from the net page
export PYTHONPATH=$PYTHONPATH:pwd:pwd/slim
Note that it's ` instead of ' around the key pwd That's my problem, hope it's helpful to you
I add export PYTHONPATH="$PYTHONPATH:tensorflow/models/research:/tensorflow/models/research/slim" in my .bashrc file, then source ~/.bashrc file, but I still has this problem. someone can tell me whiy
It looks like your paths are wrong (unless you have a directory called "tensorflow" at the root of your filesystem, in which case you are missing a '/' at the beginning of your first path)
try to include the absolute path. e.g.:
export PYTHONPATH="$PYTHONPATH:/home/kochsnow/tensorflow/models/research:/home/kochsnow/tensorflow/models/research/slim"
Thank you! It works!
发件人:Jeremiah Harbach [email protected] 发送时间:2018年8月31日(星期五) 02:15 收件人:tensorflow/models [email protected] 抄 送:aweichina [email protected]; Comment [email protected] 主 题:Re: [tensorflow/models] ImportError: No module named nets (#1842)
It looks like your paths are wrong (unless you have a directory called "tensorflow" at the root of your filesystem, in which case you are missing a '/' at the beginning of your first path) try to include the absolute path. e.g.: export PYTHONPATH="$PYTHONPATH:/home/kochsnow/tensorflow/models/research:/home/kochsnow/tensorflow/models/research/slim" — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
I encountered the same problem on windows. What I did was, I just copied the entire nets folder from slim directory to C:\Python\Python35\Lib\site-packages\object_detection-0.1-py3.5.egg (where I installed object_detection API). Then the error is completely gone.
No working for me :/
I am able to run on a local machine by adding the right slim path to PYTHONPATH. But when I am trying to run on google colab I am getting error even though I added the slim path with:
# From tensorflow/models/research/
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
Here is my error messages:
Traceback (most recent call last):
File "legacy/train.py", line 51, in <module>
from object_detection.builders import model_builder
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/builders/model_builder.py", line 35, in <module>
from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in <module>
from nets import inception_resnet_v2
ModuleNotFoundError: No module named 'nets'
I am able to run on a local machine by adding the right slim path to PYTHONPATH. But when I am trying to run on google colab I am getting error even though I added the slim path with:
# From tensorflow/models/research/ export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slimHere is my error messages:
Traceback (most recent call last): File "legacy/train.py", line 51, in <module> from object_detection.builders import model_builder File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/builders/model_builder.py", line 35, in <module> from object_detection.models import faster_rcnn_inception_resnet_v2_feature_extractor as frcnn_inc_res File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/models/faster_rcnn_inception_resnet_v2_feature_extractor.py", line 28, in <module> from nets import inception_resnet_v2 ModuleNotFoundError: No module named 'nets'
set PYTHONPATH=C:\Tensorflow\models;C:\Tensorflow\models\research;C:\Tensorflow\models\research\slim set PATH=%PATH%;%PYTHONPATH% Set environment EVERYTIME when activate tensorflow gpu
or copy & paste Slim folder content in C:\ProgramData\Anaconda3\envs\tensorflow_cpu\Lib\site-packages\object_detection-0.1-py3.5.egg\ {here}
set PYTHONPATH=C:\Tensorflow\models;C:\Tensorflow\models\research;C:\Tensorflow\models\research\slim set PATH=%PATH%;%PYTHONPATH%
I think there no C in google colab. Results from above command
/bin/bash: C:Tensorflowmodelsresearch: command not found
/bin/bash: C:Tensorflowmodelsresearchslim: command not found
/bin/bash: line 0: fg: no job control