1

I am using a virtual box to build network simulator 3(ns3), Ubuntu version: Linux Server 20.04 LTS

the Linux command that I had executed are

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc g++ python python3 -y
sudo apt-get install python3-setuptools git mercurial -y
sudo apt-get install zip unzip  
apt-get install cmake libc6-dev libc6-dev-i386 libclang-6.0-dev llvm-6.0-dev automake -y

sudo apt-get install -y python-gi-cairo 
sudo apt-get install -y gir1.2-gtk-3.0  
sudo apt-get install -y python-dev  
sudo apt-get install -y python3-dev 
sudo apt-get install -y qt5-default 
sudo apt-get install -y python3-pygraphviz
sudo apt install python3-pip
sudo apt-get install -y graphviz libgraphviz-dev
sudo pip3 install pygraphviz --install-option='--include-path=/usr/include/graphviz' --install-option='--library-path=/usr/lib/graphviz'

Then I use the bake to install the ns3 through following this page: install ns3 with bake

although the "bake.py show" tell me that pygraphvix is Missing, but since it is not an essential dependency, so I ignore it and continue build the ns3

after i successfully built the ns3, I follow the instruction here to execute the "./waf shell" command in the folder "/source/ns-3.29"

then I run the command and get the error:

root@ns3simulator:/home/ns3/source/ns-3.29# python3 examples/wireless/mixed-wired-wireless.py
Traceback (most recent call last):
  File "examples/wireless/mixed-wired-wireless.py", line 54, in <module>
    import ns.applications
ModuleNotFoundError: No module named 'ns'

Could anyone please help me for this?Thanks in advance.

  • Sounds like `bake` picked up `python` (i.e., Python 2), not Python 3. – 9769953 May 08 '20 at 02:16
  • You may want to try and create a virtual environment for Python 3, activate, then use `bake` to install the dependencies and ns3. – 9769953 May 08 '20 at 02:17
  • I still don't know what happen to the question above, but I make it to import "ns" module in python through build the ns3 manually instead of using the bake. Thank you. [ns3_manual_installation](https://www.nsnam.org/wiki/Installation#Building_ns-3_with_build.py) – Tok Chang Wenn May 08 '20 at 12:51

2 Answers2

0

The problem
"import ns.applications" ModuleNotFoundError: No module named 'ns'

is because there is a problem with the ns-3 installation and it is not able to do python binding itself and you need to manually configure it.

In my case, I have python 2.7 also installed

Go to

-> cd [PATH-to-your-ns3.29] -> /usr/bin/python2.7 ./waf configure

it will enable the python binding like this

Waf configuration

after this when you can see the python binding enabled you can run your python script without any error.

Hope it helps !!!

ImKunal
  • 1
  • 1
0
./ns3 configure --enable-python-bindings

Then run the python example. The libraries should get built. Here

Elham mey
  • 1
  • 1