Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named nets, r0.12 #729

Closed
hannan-sultan opened this issue Dec 9, 2016 · 22 comments
Closed

ImportError: No module named nets, r0.12 #729

hannan-sultan opened this issue Dec 9, 2016 · 22 comments
Assignees

Comments

@hannan-sultan
Copy link

I am trying to run resnet_v2.py from provided modles but getting error ImportError: No module named nets.
I have done following
First installing slim
cd $HOME/tensorflow git clone https://github.com/tensorflow/models/

To verify that this has worked, execute the following commands; it should run
without raising any errors.

cd $HOME/tensorflow/models/slim python3 -c "from nets import cifarnet; mynet = cifarnet.cifarnet"
I got no error.

But when I run following gives error "ImportError: No module named nets". I have also tried
cd $HOME/tensorflow/models/slim/ python3 -c "from nets import resnet_utils"

Got not error. Also build using bazel build nets output INFO: Found 1 target... Target //slim:nets up-to-date (nothing to build) INFO: Elapsed time: 0.096s, Critical Path: 0.00s

Same thing happen when try to run Inception with error ImportError: No module named inception

I don't know why this is not working.

@hannan-sultan
Copy link
Author

@michaelisard I posted the here because of no response of #6211 . Yet no response, closed both issues. (Y)

@michaelisard
Copy link

I left this one open but haven't had a chance to respond yet.

@hannan-sultan
Copy link
Author

OK. I hope I get response asap.

@ahundt
Copy link
Contributor

ahundt commented Dec 12, 2016

I'm not encountering this problem with python 2.7. in ~/src/tf_models/slim on my machine with r0.12 I run python -c "from nets import cifarnet; mynet = cifarnet.cifarnet" and get:

± python  -c "from nets import cifarnet; mynet = cifarnet.cifarnet"
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so.8.0 locally

Though I do encounter the following, I expect it can be fixed with some python path configuration:

~/src/tf_models/slim on master
± python nets/resnet_v2_test.py
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so.8.0 locally
Traceback (most recent call last):
  File "nets/resnet_v2_test.py", line 24, in <module>
    from nets import resnet_utils
ImportError: No module named nets
-> [1]

@hannan-sultan
Copy link
Author

@adarob Running python -c "from nets import cifarnet; mynet = cifarnet.cifarnet" gives no error if run the command in models > slim folder.
screenshot from 2016-12-13 12-52-41

I don't know the reason why this isn't working.

@jumpynitro
Copy link

you solve this problem?, i got the same issue

@hannan-sultan
Copy link
Author

No, I have found no solution.

@hannan-sultan
Copy link
Author

@sguada Any updates? With latest version installation, I am still getting the error.

@pzz2011
Copy link

pzz2011 commented Feb 21, 2017

If you understand the relative import and absolut import of python, then you will understand why
""python -c "from nets import cifarnet; mynet = cifarnet.cifarnet""" will reported error @CodeLoverr

@anuj2rock
Copy link

@CodeLoverr Here is your solution tried and tested . Just add slim path to your PYTHONPATH in bashrc file
export PYTHONPATH="$PYTHONPATH:/home/airig/tf-src/tensorflow/models/slim"

And it works!!

@thomasjhuang
Copy link

@anuj2rock This solution works for me!

@datomnurdin
Copy link

BTW it's not worked on Github.

@ghost
Copy link

ghost commented Sep 6, 2017

Hello,

When I try your solution I have : export nis not recognized ...

export PYTHONPATH="$PYTHONPATH:/... is ok for windows ?

Sorry, it might be a stupid question.. I am new in python..

@auzair92
Copy link

@Madekwe You can try manually adding the path to system variables. In Control Panel, look for "Edit the system environment variables", then "Environment Variables..." and add append your desired path to the end of "Path" variable. Hope it helps!

@toseef-ahmd
Copy link

The error is accruing because nets is not a module. It is a folder that contains different modules. Instead of writing from nets import inception_utils simply write import inception_utils Similarly for cifarnet, type import cifarnet rather than from nets import cifarnet. This will remove the error no module named nets

@itsmeolivia
Copy link
Contributor

Automatically closing due to lack of recent activity. Please update the issue when new information becomes available, and we will reopen the issue. Thanks!

@ChandanVerma
Copy link

Can someone provide a proper solution for windows?

@ghost
Copy link

ghost commented Apr 9, 2018

same issue for mac OS, I am using pip3 PyCharm with Python 3.6.

@burtonw0814
Copy link

I had a lot of trouble with this too on Windows even after updating the PYTHONPATH. I found a brute force solution.

For all files where they use "from nets import...", I switched it too "from slim.nets import ..."

This requires going through a couple dozen files and updating, takes about 20 minutes max.

Hopefully this is useful to someone!

@mknow
Copy link

mknow commented Aug 14, 2018

@burtonw0814 it works, thx

@ljmouline
Copy link

@burtonw0814 It doesn't work for me: I still have an issue saying:
ModuleNotFoundError: No module named 'slim'

@burtonw0814
Copy link

@ljmouline Perhaps you could try specifying even more context:

"from rest.of.path.slim.nets import..."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests