python - 无法调用 Waf - ImportError:无法导入名称脚本
问题描述
我正在尝试安装 ns-3 网络模拟器,并且正在构建一个简单的脚本,它将在全新安装最新的 Ubuntu LTS OS(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
给出以下输出:
输出(pastebin)
解决方案
ns-3 在发行版中捆绑了 waf。当您从头开始构建时,您要做的第一件事就是运行./waf configure
,以便将 waf 模块解压缩到一个名为waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc
. 丢失Scripting
的应该是文件waf3-2.0.15-ff6573b86ad5ff5d449c8852ad58b8bc/waflib/Scripting.py
我不知道出了什么问题,因为你没有提供足够的线索。但是检查ns3目录中是否有我上面提到的目录,如果有,删除它然后./waf configure
再次运行。
推荐阅读
- arrays - 过滤具有特定属性 Swift 的 json 数组
- vuejs2 - 使用 v-for 过滤数据库中的数据
- mysql - 修复自动增量键 mysql 数据库的顺序
- spring-boot - Spring Security 5 OAuth2 WebClient [client_authorization_required] 客户端注册 ID 所需的授权:假人”
- node.js - 节点承诺链是否无法同步执行?
- php - 如何在limesurvey中上传文件
- python - 机器人框架 - UnicodeDecodeError:“ascii”编解码器无法解码位置 49 的字节 0xe9:输入文本时序数不在范围内(128)
- html - 为什么我的元素的内容区域超出其父元素?
- c++ - 可以乘一个旋转矩阵来旋转方向向量(vec 3)吗?
- lua - 有没有更快的方法在 lua 中找到素数?