Bugzilla – Bug 2734
visualizer calls PySys_SetArgv(int, wchar_t**) with char**
Last modified: 2019-04-15 17:45:42 EDT
The problem has been reported in this thread:
It seems that the Manjaro Linux distribution is not keen to convert a char** to a wchar_t**
Perhaps other Linux distributions are more relaxed.
Created attachment 3214 [details]
Patch to fix python 3 compatibility in visualizer
The bug is caused by changes in Python3. In which the strings are in UTF-8 and it is required to parse locale information in command line arguments. The attached patch should fix the problem.
However, it is not end of the story. As it discovers a new bug (should I report it as new bug?) with `import ns.mesh`. This bug can be reproduced with adding this import to any python example.
Waf: Entering directory `/home/Code/ns3/ns-3-dev-git/build/debug'
[2602/2652] Linking build/debug/scratch/scratch-simulator
[2604/2652] Linking build/debug/scratch/subdir/subdir
[2606/2652] Linking build/debug/utils/ns3-dev-test-runner-debug
[2612/2652] Linking build/debug/utils/ns3-dev-print-introspected-doxygen-debug
Waf: Leaving directory `/home/chwalisz/Code/ns3/ns-3-dev-git/build/debug'
Build commands will be stored in build/debug/compile_commands.json
'build' finished successfully (11.530s)
TypeError: PyModule_AddObject() needs non-NULL value
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "examples/wireless/wifi-ap.py", line 32, in <module>
SystemError: <built-in function __import__> returned a result with an error set
Command ['/home/.local/share/virtualenvs/ns3-QbuZIpeN/bin/python', 'examples/wireless/wifi-ap.py'] exited with code 1
Thank you for this patch; I will test and apply if it works for me.
Regarding this error:
> TypeError: PyModule_AddObject() needs non-NULL value
I believe that this is just due to stale Python bindings and I will fix this separately.
I pulled updated bindings but discovered further incompatibilities in the Python code for the visualizer.
Is actually Python 3 intended to be supported by ns-3? Imho it should be as the Py2 support is going to end in near future.
(In reply to Mikołaj Chwalisz from comment #3)
> I pulled updated bindings but discovered further incompatibilities in the
> Python code for the visualizer.
> Is actually Python 3 intended to be supported by ns-3? Imho it should be as
> the Py2 support is going to end in near future.
Yes, Python 3 is intended to be fully supported, but I believe that most maintainers use distros still defaulting to Python 2, and the visualizer testing is not automated so it may fall through the cracks. Patches would be welcome in this regard because the visualizer is not being actively maintained by anyone.
After applying the patch, the C++ code successfully builds but when I try:
./waf --pyrun src/flow-monitor/examples/wifi-olsr-flowmon.py -vis
", line 700, in Visualizer
if _import_error is None:
NameError: name '_import_error' is not defined
Test machine is a venv on Linux Mint 19 Python 3.6.6.
I have some further information. This patch introduces some regressions on Python 2, so more work is needed.
First, base.py needs:
from __future__ import print_function
More importantly, when I try to run this command on a patched ns-3-dev with Python 2:
$ ./waf --pyrun src/flow-monitor/examples/wifi-olsr-flowmon.py --vis
I get many instances of the following:
No visualization support (cannot import name core).
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "/ns-3-allinone/ns-3-dev/src/visualizer/visualizer/core.py", line 1847, in start
RuntimeError: maximum recursion depth exceeded while calling a Python object
Created attachment 3245 [details]
A little bit extended patch to make Visualizer work with Python3. Works for me, but didn't test with Python2.
Thanks, I tried the latest and it didn't work for me on Python 2.7. However, I have a patch now (this patch plus some others) that seems to work for both Python 2.7 and Python 3.6; can you please test it?
Or if you prefer, it is on the 'visualizer-upgrade' branch of