I am working on a docker and using ROS 1 noetic as of now.
For certain reasons I do not want to distribute .py files as end user do not need to understand what is inside there. So I am using .pyc files generated using python module compileall.
When I try to launch .pyc file on the local machine with Ubuntu (not on the docker) it works perfectly fine. But when I put it inside the docker, it throws the following error while launching.
If it is a script, you may be missing a '#!' declaration at the top.
I have already provided execution permition to the file. Any idea what am I missing here?
[Update]
Progress.. A different error.. After updating CMakeLists.txt by adding following,
catkin_install_python(PROGRAMS
scripts/control_lib.pyc
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
Now I am getting RuntimeError: Bad magic number in .pyc file
But it doesn't make sense as file is compilled on the docker.
[Try it yourself]
Here is a simple example to reproduce the error. https://github.com/aarsht7/pyc_test
It contains simple talker node with python.
When used .py file in the roslaunch, it behaves as it should be. While usin .pyc file in roslaunch, it throws RuntimeError: Bad magic number in .pyc file
python -m compileall `rospack find talker`
,<node pkg="talker" type="talker.sh" name="talker_pyc" output="screen"/>
then in scripts/talker.sh wrapper script:#!/bin/bash
python `rospack find talker`/scripts/__pycache__/talker.cpython-311.pyc
$\endgroup$RLException: Unable to launch If it is a script,..
(I think any time you sawBad magic
that's from running a pyc from a different python version, probably the outside one)- but the wrapper worked. So the issue is something different with any combination of ros or python versions or the docker environment vs. outside docker. $\endgroup$