Problem while running python programs

65 views
Skip to first unread message

Asayel A

unread,
Jan 31, 2019, 12:38:50 AM1/31/19
to ns-3-users
Greetings,

I have a query regarding running a python program. When I try and run and python program from the tutorial folder it shows me the following:

a@a:~/repos/ns-3-allinone/ns-3.26$ ./waf --pyrun first
Waf: Entering directory `/home/asayel_25/repos/ns-3-allinone/ns-3.26/build'
Waf: Leaving directory `/home/asayel_25/repos/ns-3-allinone/ns-3.26/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (10.737s)

Modules built:
antenna                   aodv                      applications              
bridge                    buildings                 config-store              
core                      csma                      csma-layout               
dsdv                      dsr                       energy                    
fd-net-device             flow-monitor              internet                  
internet-apps             lr-wpan                   lte                       
mesh                      mobility                  mpi                       
netanim (no Python)       network                   nix-vector-routing        
olsr                      point-to-point            point-to-point-layout     
propagation               sixlowpan                 spectrum                  
stats                     tap-bridge                test (no Python)          
topology-read             traffic-control           uan                       
virtual-net-device        wave                      wifi                      
wimax                     

Modules not built (see ns-3 tutorial for explanation):
brite                     click                     openflow                  
visualizer                

/usr/bin/python: can't open file 'first': [Errno 2] No such file or directory
Command ['/usr/bin/python', 'first'] exited with code 2


Can anyone help?

Tom Henderson

unread,
Jan 31, 2019, 1:03:17 AM1/31/19
to ns-3-...@googlegroups.com, Asayel A
Try './waf --pyrun examples/tutorial/first.py'

Unlike C++ examples, you need to specify the relative path to the python
program, and include the program full name with the .py suffix.

- Tom

Asayel A

unread,
Jan 31, 2019, 1:11:05 AM1/31/19
to ns-3-users
I tried to do it, but I've got the same error
a@a:~/repos/ns-3-allinone/ns-3.26$ ./waf --pyrun examples/tutorial/first.py
Waf: Entering directory `/home/asayel_25/repos/ns-3-allinone/ns-3.26/build'
Waf: Leaving directory `/home/asayel_25/repos/ns-3-allinone/ns-3.26/build'
Build commands will be stored in build/compile_commands.json
'build' finished successfully (4.120s)

Modules built:
antenna                   aodv                      applications              
bridge                    buildings                 config-store              
core                      csma                      csma-layout               
dsdv                      dsr                       energy                    
fd-net-device             flow-monitor              internet                  
internet-apps             lr-wpan                   lte                       
mesh                      mobility                  mpi                       
netanim (no Python)       network                   nix-vector-routing        
olsr                      point-to-point            point-to-point-layout     
propagation               sixlowpan                 spectrum                  
stats                     tap-bridge                test (no Python)          
topology-read             traffic-control           uan                       
virtual-net-device        wave                      wifi                      
wimax                     

Modules not built (see ns-3 tutorial for explanation):
brite                     click                     openflow                  
visualizer                

Traceback (most recent call last):
  File "examples/tutorial/first.py", line 16, in <module>
    import ns.applications
ImportError: No module named ns.applications
Command ['/usr/bin/python', 'examples/tutorial/first.py'] exited with code 1

Tom Henderson

unread,
Jan 31, 2019, 9:22:30 AM1/31/19
to ns-3-...@googlegroups.com, Asayel A
On 1/30/19 10:11 PM, Asayel A wrote:
> I tried to do it, but I've got the same error

I believe that ns-3.26 release was the first one with the 'check-config'
option to Waf.

When you run './waf --check-config' (or when you view the configure
output), do you see Python bindings enabled or disabled? You need to see:

Python Bindings : enabled

- Tom

Asayel A

unread,
Jan 31, 2019, 3:12:47 PM1/31/19
to ns-3-users
It is disabled, how can I fix it?


 
a@a:~/repos/ns-3-allinone/ns-3.26$ ./waf --check-config
Waf: Entering directory `/home/asayel_25/repos/ns-3-allinone/ns-3.26/build'
---- Summary of optional NS-3 features:
Build profile                 : debug
Build directory               : 
BRITE Integration             : not enabled (BRITE not enabled (see option --with-brite))
DES Metrics event collection  : not enabled (defaults to disabled)
Emulation FdNetDevice         : enabled
Examples                      : enabled
File descriptor NetDevice     : enabled
GNU Scientific Library (GSL)  : enabled
Gcrypt library                : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.)
GtkConfigStore                : enabled
MPI Support                   : not enabled (option --enable-mpi not selected)
NS-3 Click Integration        : not enabled (nsclick not enabled (see option --with-nsclick))
NS-3 OpenFlow Integration     : not enabled (OpenFlow not enabled (see option --with-openflow))
Network Simulation Cradle     : not enabled (NSC not found (see option --with-nsc))
PlanetLab FdNetDevice         : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
PyViz visualizer              : not enabled (Python Bindings are needed but not enabled)
Python Bindings               : not enabled (PyBindGen version not correct and newer version could not be retrieved)
Real Time Simulator           : enabled
SQlite stats data output      : enabled
Tap Bridge                    : enabled
Tap FdNetDevice               : enabled
Tests                         : enabled
Threading Primitives          : enabled
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
XmlIo                         : enabled

Tom Henderson

unread,
Jan 31, 2019, 4:04:39 PM1/31/19
to ns-3-...@googlegroups.com, Asayel A
On 1/31/19 12:12 PM, Asayel A wrote:
> It is disabled, how can I fix it?

You need to have Python development libraries installed (see the
installation wiki) and then you need to have the correct version of
Pybindgen installed per your ns-3 version.

If you downloaded ns-3.26 release as part of the 'allinone' source
archive, then pybindgen is already there (one level up from ns-3.26), so
you probably need to just add python development libraries (e.g. sudo
apt-get install python-dev) for your system.

This documentation may also help:

https://www.nsnam.org/docs/release/3.29/manual/singlehtml/index.html#document-python

- Tom

Asayel A

unread,
Feb 1, 2019, 12:29:12 PM2/1/19
to ns-3-users
after downloading and trying to run I got this error

 a@a:~/repos/ns-3-allinone/ns-3.26$ ./waf --pyrun /home/asayel_25/repos/ns-3-allinone/ns-3.26/examples/tutorial/third
Traceback (most recent call last):
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 110, in waf_entry_point
    run_commands()
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 167, in run_commands
    parse_options()
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Scripting.py", line 140, in parse_options
    Context.create_context('options').execute()
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Options.py", line 146, in execute
    super(OptionsContext,self).execute()
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 93, in execute
    self.recurse([os.path.dirname(g_module.root_path)])
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 134, in recurse
    user_function(self)
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/wscript", line 246, in options
    opt.recurse('src')
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 134, in recurse
    user_function(self)
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/src/wscript", line 49, in options
    opt.recurse(module, mandatory=False)
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 128, in recurse
    wscript_module=load_module(node.abspath(),encoding=encoding)
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/.waf-1.8.19-b1fc8f7baef51bd2db4c2971909a568d/waflib/Context.py", line 354, in load_module
    try:exec(compile(code,path,'exec'),module.__dict__)
  File "/home/asayel_25/repos/ns-3-allinone/ns-3.26/src/pybindgen/wscript", line 4, in <module>
    from wutils import get_version, generate_version_py
ImportError: cannot import name get_version

Reply all
Reply to author
Forward
0 new messages