No module named 'ns.applications'; 'ns' is not a package

1,193 views
Skip to first unread message

Ali HosseinAliPour

unread,
Oct 27, 2022, 9:16:05 AM10/27/22
to ns-3-users
Hello everyone.

 I am using ns-3.36.1 on Ubuntu 22.04.1 . 

I have used this command to copy first.py into scratch folder :

ali@ali-virtual-machine:~/ns-allinone-3.36.1/ns-3.36.1 $ cp examples/tutorial/first.py scratch/myfirst.py 

and I have used this command to run it 

ali@ali-virtual-machine:~/ns-allinone-3.36.1/ns-3.36.1 $ ./ns3 build
ali@ali-virtual-machine:~/ns-allinone-3.36.1/ns-3.36.1   $ ./ns3 run scratch/myfirst.py

But, I always get this following error:

0/2] Re-checking globbed directories...
ninja: no work to do.
Traceback (most recent call last):
  File "/home/ali/ns-allinone-3.36.1/ns-3.36.1/scratch/myfirst.py", line 16, in <module>
    import ns.applications
ModuleNotFoundError: No module named 'ns.applications'; 'ns' is not a package
Command 'python3 scratch/myfirst.py' returned non-zero exit status 1.

After running       $ ./ns3 build,      I found Python Bindings is OFF in my system.
According to my research, my mentioned problem might be caused by Python Bindings being OFF. 
However, I do not know how to turn it on.
It would be greatly appreciated if you could assist me.
Thanks in advance.



Gabriel Ferreira

unread,
Oct 27, 2022, 3:25:27 PM10/27/22
to ns-3-users
./ns3 configure --enable-python-bindings
Then run the python example. The libraries should get built.

Message has been deleted

Ali HosseinAliPour

unread,
Oct 29, 2022, 1:28:33 AM10/29/22
to ns-3-users
Thank you very much for your reply.

My problem has been solved and Python bindings have been enabled successfully.

I recently installed NS3 and am unfamiliar with this software. I have searched the Internet a lot to learn such commands in NS3, but have not found anything helpful. Could you please introduce a source for learning these commands in NS3?

Gabriel Ferreira

unread,
Oct 29, 2022, 2:43:52 PM10/29/22
to ns-3-users
Do you mean the ns3 script commands? You can use ./ns3 --help to check the available commands.

Ali HosseinAliPour

unread,
Oct 30, 2022, 1:55:11 AM10/30/22
to ns-3-users
Actually, I mean a website or a booklet teaching the NS3 new version's command. 
Reply all
Reply to author
Forward
0 new messages