python - 无法调用 Waf - ImportError : cannot import name Scripting

标签 python ns-3 waf

我正在尝试安装 ns-3 网络模拟器,并且正在构建一个简单的脚本,该脚本将在全新安装最新的 Ubuntu LTS 操作系统(18.04)时安装所有先决条件。

一切都很顺利,但是一旦我尝试运行任何测试,我就会收到以下错误:

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'

当我简单地尝试时也会发生这种情况: ./waf --help

脚本并没有做任何引人注目的事情,但这里只是以防万一。必须使用 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 给出以下输出: output (pastebin)

最佳答案

ns-3 在发行版中捆绑了 WAF。当您从头开始构建时,您要做的第一件事就是运行 ./waf configure ,以便将 waf 模块解压到名为 waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc 的目录中。缺少的 Scripting 应该是文件 waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc/waflib/Scripting.py

我不知道出了什么问题,因为你没有提供足够的线索。但请检查一下 ns3 目录中是否有我上面提到的目录,如果有,请将其删除,然后再次运行 ./waf configure

关于python - 无法调用 Waf - ImportError : cannot import name Scripting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56152916/

相关文章:

python - 使用 PyInstaller 打包时找不到 SpaCy 模型

python - 使用 Python 搜索字符串

c++ - 使用ns3在C++中构建拓扑

compiler-errors - 为arduino yun交叉编译ndn-cxx

python - 使用 waf,如何将构建目录中的文件引用为另一个构建命令的输入?

python - Altair:将串联图表中的配色方案分开

python - 如何将 GEKKO 中的值转换为 float

c++ - FlowMonitor 不显示统计数据,但 PyViz 和跟踪文件显示它

c++ - 使用 NS3 和 std::thread 的并行模拟

c++ - 使用 waf 构建系统将程序与 Boost.Asio 链接