Rorschach
Rorschach

Reputation: 764

Waf can't be invoked - ImportError: cannot import name Scripting

I'm trying to install ns-3 network simulator, and I'm building a simple script that would install all prerequisites on fresh install of latest Ubuntu LTS OS(18.04).

Everything goes smooth but once I try to run any test, I get following error:

Traceback (most recent call last):   
 File "./source/ns-3.29/test.py", line 1942, in <module>
   sys.exit(main(sys.argv))   
 File "./source/ns-3.29/test.py", line 1939, in main
   return run_tests()   
 File "./source/ns-3.29/test.py", line 1010, in run_tests
   read_waf_config()   File "./source/ns-3.29/test.py", line 579, in read_waf_config
   for line in open(".lock-waf_" + sys.platform + "_build", "rt"): 
 IOError: [Errno 2] No such file or directory: '.lock-waf_linux2_build'

This also happens when I try simply: ./waf --help

Script doesn't do anything spectacular, but here it is just in case. It has to be invoked using sudo

#!/bin/bash
echo "Installing..."

#   basic OS update
apt update
apt upgrade -y
apt dist-upgrade -y
apt autoremove -y
apt autoclean -y

#   install prerequisites
apt install git -y
apt install gcc -y
apt install g++ -y
apt install mercurial -y
apt install cvs -y
apt install bzr -y
apt install make -y
apt install cmake -y
apt install qt5-default -y
apt install qtcreator -y
apt install python-gi-cairo -y
apt install gir1.2-goocanvas-2.0 -y
apt install python-pygraphviz -y
apt install python-dev -y
apt install python-setuptools -y

##  acquire Bake
git clone https://gitlab.com/nsnam/bake

#   add Bake to PATH
export BAKE_HOME=`pwd`/bake 
export PATH=$PATH:$BAKE_HOME
export PYTHONPATH=$PYTHONPATH:$BAKE_HOME

#   check if all valid
bake.py check

#   configure Bake for ns-3
bake.py configure -e ns-3.29
bake.py show

#   download and build ns-3
bake.py download
cd ./source/ns-3.29/ && ./waf configure && cd ../../
bake.py build
#instead of 3 lines above this comment there was previously just "bake.py deploy"

./source/ns-3.29/test.py #this causes an error

echo "Finished Install!"

./waf configure gives following output: output (pastebin)

Upvotes: 3

Views: 1518

Answers (2)

Parth Dodiya
Parth Dodiya

Reputation: 21

try to run the same command using sudo. It worked for me.

Upvotes: 2

adrtam
adrtam

Reputation: 7211

ns-3 bundled waf in the distribution. When you build from scratch, the first thing you want to do is to run ./waf configure so that you have the waf module unpacked to a directory named like waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc. The missing Scripting is supposed to be the file waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc/waflib/Scripting.py

I don't know what went wrong as you didn't provide enough clue. But check if you have the directory I mentioned above in the ns3 directory, if so, delete it then run ./waf configure again.

Upvotes: 3

Related Questions