Python bindings taking too long to import

395 views
Skip to first unread message

Ornab

unread,
Jul 12, 2023, 10:40:11 AM7/12/23
to ns-3-users
Hi, 
I am new to NS-3 and was having some trouble with the Python bindings. After building  NS3 (I tried the Debug, Optimized, and Release profiles), when I try to run first.py, the program first builds NS3 and then freezes over, giving me results about 45-50 mins later. Using Print statements, I found that all the time is going in the import statements. Could this be an issue with the installation?
I am using NS3 on WSL with VSCode on an i5 machine with 8GB Ram. 

While configuring NS3, I get the message:
-- NS3_BINDINGS_INSTALL_DIR was not set. The python bindings won't be installed with ./ns3 install.
-- Set NS3_BINDINGS_INSTALL_DIR="/home/user/.local/lib/python3.10/site-packages" to install it to the default location.

But I'm not sure how do I set NS3_BINDINGS_INSTALL_DIR. Could this be the issue with the python bindings not working correctly?

Thanks in advance

Gabriel Ferreira

unread,
Jul 12, 2023, 1:42:02 PM7/12/23
to ns-3-users
Building ns-3 takes a fair amount of time if you run
./ns3 configure --enable-examples --enable-tests && ./ns3 build

This is because you are building everything. If you run
./ns3 configure --enable-examplese --enable-python-bindings && ./ns3 run first.py

It will build only the libraries and then run the python script.

Loading the bindings can be pretty slow (from ns import ns). 
Not much I can do to speed it up. 
It runs an awful lot of stuff from cling and cppyy to build the bindings at runtime and make it available.
I haven't tried caching it to disk and then loading, but may be an option (like shader caches used in games, where you compile once and load later).

Regarding the NS3_BINDINGS_INSTALL_DIR. Don't touch that. It is meant for repackagers, not end-users.

Ornab

unread,
Jul 12, 2023, 3:11:06 PM7/12/23
to ns-3-users
Got it, Thanks! 
Reply all
Reply to author
Forward
0 new messages