pythonimportcontrollersdnryu

How to fix 'ImportError: No module named ...' in Linux?


I wanted to try codes from http://csie.nqu.edu.tw/smallko/sdn/dijkstra_ryu.htm but when I try to run the codes, it doesn't work. There always 'ImportError: No module dijkstra_ryu.py' error

I am using Ubuntu 16.04.4 LTS, python 2.7.12 and 3.5.2, and ryu 4.23.

Here's what happen:

ray@raihanr:~/ryu/ryu/app$ ryu-manager dijkstra_ryu.py --observe-links
loading app dijkstra_ryu.py
Traceback (most recent call last):
File "/usr/local/bin/ryu-manager", line 9, in 
load_entry_point('ryu==4.23', 'console_scripts', 'ryu-manager')()
File "/usr/local/lib/python2.7/dist-packages/ryu/cmd/manager.py", line 98, in main
app_mgr.load_apps(app_lists)
File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 415, in load_apps
cls = self.load_app(app_cls_name)
File "/usr/local/lib/python2.7/dist-packages/ryu/base/app_manager.py", line 392, in load_app
mod = utils.import_module(name)
File "/usr/local/lib/python2.7/dist-packages/ryu/utils.py", line 104, in import_module
return importlib.import_module(modname)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
ImportError: No module named dijkstra_ryu.py

I also tried using:

ryu/ryu/app$ ryu-manager --observe-links dijkstra_ryu.py

but it keeps showing the same error

Sadly, I also try this:

:~$ryu-manager ryu/ryu/app/dijkstra_ryu.py --observe-links

then a new error shows up

ImportError: Import by filename is not supported.

I already checked every module and not missing any part.


Solution

  • I FOUND IT GUYS. the problem is in the spacing rules. the codes are messy, so we need to make it right for spacing that is 4 times when the codes are inside the definition, for, if, and etc.