[英]ns3, Python3 has no module named 'ns'
I am using a virtual box to build.network simulator 3(ns3), Ubuntu version: Linux Server 20.04 LTS我正在使用虚拟框来构建网络模拟器 3(ns3),Ubuntu 版本:Linux Server 20.04 LTS
the Linux command that I had executed are我执行的 Linux 命令是
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然后我使用 bake 通过以下页面安装 ns3: 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尽管“bake.py show”告诉我缺少 pygraphvix,但由于它不是必需的依赖项,所以我忽略它并继续构建 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"成功构建 ns3 后,我按照此处的说明在文件夹“/source/ns-3.29”中执行“./waf shell”命令
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.谁能帮我解决这个问题?提前致谢。
The problem问题
"import ns.applications" ModuleNotFoundError: No module named 'ns' “导入 ns.applications”ModuleNotFoundError:没有名为“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.是因为ns-3安装有问题,不能自己绑定python,需要手动配置。
In my case, I have python 2.7 also installed就我而言,我还安装了 python 2.7
Go to Go 至
-> cd [PATH-to-your-ns3.29] -> /usr/bin/python2.7./waf configure -> cd [PATH-to-your-ns3.29] -> /usr/bin/python2.7./waf 配置
it will enable the python binding like this它将像这样启用 python 绑定
after this when you can see the python binding enabled you can run your python script without any error.在此之后,当您看到 python 绑定已启用时,您可以运行 python 脚本而不会出现任何错误。
Hope it helps !!!希望能帮助到你 !!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.